Performance improvements by refactoring penalty and interleaveBytes#32
Merged
paulmillr merged 3 commits intopaulmillr:mainfrom Nov 16, 2025
Merged
Performance improvements by refactoring penalty and interleaveBytes#32paulmillr merged 3 commits intopaulmillr:mainfrom
paulmillr merged 3 commits intopaulmillr:mainfrom
Conversation
…lating the size of and creating the resulting array up front to avoid dynamic resizing.
…or for... of... loops.
…calculating the penalties for the various rules.
Owner
|
interleaveBytes change is great. Not sure about the loop unroll. Why did decode got slower? It's much more important vs encode. Is there any way to make it as fast? |
Contributor
Author
I imagine it's just variance in the benchmark. None of these changes touch decoding. There are definitely ways to make it faster. I think significantly, but I'd have to actually try some options.
Almost all of the performance gains are from the changes to |
Owner
|
Thank you. |
Owner
|
The PR is live in 0.5.3. |
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 free
to 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.
Includes a significant refactor of
penaltythat is much more efficient.Also makes
interleaveBytesmarginally more memory and CPU efficient by calculating the resulting array size of and creating the resulting array up front to avoid dynamic resizing. The new implementation also avoids unnecessary bounding checks.Here are some old benchmarks:
And here is the new version: