Skip to content

store ascii start/continue bitmaps in u128 instead of slices of bool#40

Merged
dtolnay merged 1 commit intodtolnay:masterfrom
Marcondiro:master
Oct 21, 2025
Merged

store ascii start/continue bitmaps in u128 instead of slices of bool#40
dtolnay merged 1 commit intodtolnay:masterfrom
Marcondiro:master

Conversation

@Marcondiro
Copy link
Contributor

@Marcondiro Marcondiro commented Oct 6, 2025

Hello,

Using slices of bools to store ASCII CONTINUE and START data results in using 2*128 bytes of memory since one entire byte is used to store each boolean.
Since ASCII chars are 128, bitmaps fit perfectly in u128 consts.

This change reduces execution time by 44% in 0%-nonascii case and by 32% in 10%-nonascii, according to the crate's benches, and reduces the static storage by ~200 bytes.
Benchmarks were run on an Intel i5-12400 system.

Thanks

Reduce execution time by 44% in 0%-nonascii case and by 32% in 10%-nonascii.
Reduce the static data size ~200 bytes.
@Marcondiro
Copy link
Contributor Author

Tested also on Apple M1 with a time reduction around 20-30%

@Marcondiro
Copy link
Contributor Author

Hello @dtolnay, do you have any feedback about this?
Thanks!

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thank you! This is an extraordinary performance improvement.

@dtolnay dtolnay merged commit 0325fd8 into dtolnay:master Oct 21, 2025
10 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