Skip to content

perf: optimize NIP-21 URI parsing in PublicKey::parse#1308

Merged
yukibtc merged 1 commit into
nostrdevkit:masterfrom
TheAwiteb:optimize-nip21-publickey-parse
Mar 31, 2026
Merged

perf: optimize NIP-21 URI parsing in PublicKey::parse#1308
yukibtc merged 1 commit into
nostrdevkit:masterfrom
TheAwiteb:optimize-nip21-publickey-parse

Conversation

@TheAwiteb

Copy link
Copy Markdown
Member

Align NIP-21 parsing performance with standard bech32 parsing. Previously, NIP-21 URIs (which are essentially bech32 strings with a prefix) took ~104% longer to parse than raw bech32 keys.

By streamlining the prefix handling, NIP-21 parsing time has been reduced by ~51%, bringing it within the expected margin of standard bech32 performance.

Benchmarks:

Bench Before (ns/iter) After (ns/iter) Δ
parse_bech32 591.20 592.77 ~0%
parse_nip21_uri 1,225.93 598.44 -51.2%

Checklist

@TheAwiteb TheAwiteb requested a review from yukibtc as a code owner March 26, 2026 22:51
Align NIP-21 parsing performance with standard bech32 parsing.
Previously, NIP-21 URIs (which are essentially bech32 strings with a
prefix) took ~104% longer to parse than raw bech32 keys.

By streamlining the prefix handling, NIP-21 parsing time has been
reduced by ~51%, bringing it within the expected margin of standard
bech32 performance.

Benchmarks:

| Bench                 | Before (ns/iter) | After (ns/iter) | Δ      |
|-----------------------|------------------|-----------------|--------|
| parse_bech32          | 591.20           | 592.77          | ~0%    |
| parse_nip21_uri       | 1,225.93         | 598.44          | -51.2% |

Signed-off-by: Awiteb <a@4rs.nl>
@TheAwiteb TheAwiteb force-pushed the optimize-nip21-publickey-parse branch from e36d346 to 5d9d97e Compare March 26, 2026 22:51
@codecov

codecov Bot commented Mar 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.62%. Comparing base (b59bb58) to head (5d9d97e).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1308      +/-   ##
==========================================
- Coverage   69.64%   69.62%   -0.02%     
==========================================
  Files         188      188              
  Lines       31255    31251       -4     
==========================================
- Hits        21769    21760       -9     
- Misses       9486     9491       +5     
Flag Coverage Δ
rust 69.62% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TheAwiteb

Copy link
Copy Markdown
Member Author

This is the report using criterion #1310

image

@yukibtc yukibtc merged commit 2f3a820 into nostrdevkit:master Mar 31, 2026
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants