perf: faster pack/unpack (no breaking changes) - #35
Open
adarshmadrecha wants to merge 1 commit into
Open
Conversation
Reduce pack allocations with tagged-integer AST leaves, pre-sized containers, cached base36, static escape maps, and join-based structure emission. Add decode fast-path. Public API and packed output unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Internal performance improvements to
pack/unpackwith no API or packed-format changes.Changes
{ type, index }objects (less GC on pack)Object.keys/ known lengths)join(avoids quadratic concat)Object.create(null)dictionariesBenchmark (same machine, before vs after)
Node v25 / win32 x64 / i5-1340P — full table in
benchmark/COMPARISON.md.Examples:
geojson-largepack: 177 → 294 ops/s (+66%), unpack: 457 → 478 ops/s (+5%)api-largepack: 153 → 270 ops/s (+77%)ecommerce-largepack: 102 → 220 ops/s (+116%)CPU stays ~100% of one core during the hot loop (CPU-bound); wall-clock CPU time per op drops with throughput. RSS stays in a similar band.
Related: benchmark harness in #34.
Test plan
npm test— 22/22 passing (byte-identical packed fixtures)