Skip to content

Conversation

devinivy
Copy link
Contributor

Making a performance improvement here to rfc4648 base decoding (e.g. base64, base32, base16). On each decoding call we were building-up a dictionary mapping alphabet characters to their index—now this dictionary is built ahead of time.

Benching CID.parse() against 100,000 base32 CIDs sees an improvement of about 33-35% with this change (node v22.15.1 / macOS / ARM).

@devinivy devinivy changed the title perf: improve rfc4648 base decoding fix: perf improvement for rfc4648 base decoding May 19, 2025
Copy link
Member

@rvagg rvagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@rvagg rvagg merged commit 900b5f6 into multiformats:master May 20, 2025
20 of 21 checks passed
github-actions bot pushed a commit that referenced this pull request May 20, 2025
## [13.3.5](v13.3.4...v13.3.5) (2025-05-20)

### Bug Fixes

* **perf:** improve rfc4648 base decoding ([#323](#323)) ([900b5f6](900b5f6))
Copy link

🎉 This PR is included in version 13.3.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants