Skip to content

Move to using bit sets for ScriptExtension #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2020
Merged

Move to using bit sets for ScriptExtension #3

merged 2 commits into from
Jan 12, 2020

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Jan 11, 2020

Should be much faster and cleaner, since the actual implementation is no longer using a ton of autogenerated enum matches and is instead using bit operations in the handwritten part of the crate.

Fixes #2

Probably won't merge till I add tests.

@Manishearth Manishearth force-pushed the bits branch 4 times, most recently from d03aa82 to 0609dae Compare January 11, 2020 10:31
@Manishearth
Copy link
Member Author

Some tests exist, I kinda want to add more including some manual ones (and maybe pull in quickcheck)

@Manishearth
Copy link
Member Author

I also need to check perf of the important operations

@Manishearth
Copy link
Member Author

Manishearth commented Jan 11, 2020

Benchmark numbers:

New:
test tests::bench_ext_intersection    ... bench:           2 ns/iter (+/- 0)
test tests::bench_ext_to_script       ... bench:           5 ns/iter (+/- 0)
test tests::bench_script_to_ext       ... bench:           1 ns/iter (+/- 0)
test tests::bench_script_intersection ... bench:           3 ns/iter (+/- 0)
test tests::bench_to_vec              ... bench:         156 ns/iter (+/- 37)
test tests::bench_string_ext          ... bench:       7,175 ns/iter (+/- 655)

Old:
test tests::bench_ext_intersection    ... bench:           5 ns/iter (+/- 0)
test tests::bench_ext_to_script       ... bench:           0 ns/iter (+/- 0)
test tests::bench_script_to_ext       ... bench:           0 ns/iter (+/- 0)
test tests::bench_script_intersection ... bench:           7 ns/iter (+/- 0)
test tests::bench_to_vec              ... bench:          14 ns/iter (+/- 1)
test tests::bench_string_ext          ... bench:       7,292 ns/iter (+/- 631)

It's better for most operations except for conversions and to_vec (which is to be expected). The common one -- converting a Script to a ScriptExtension -- is still pretty fast. The actual lookup operation seems to dominate for matching.

The perf wins (and losses) don't really matter here, but it's always good to start measuring early. IMO this PR is worth it just for moving all the weird stuff out of autogeneration.

@Manishearth Manishearth force-pushed the bits branch 13 times, most recently from e34e1a8 to ee222f7 Compare January 12, 2020 06:25
@Manishearth Manishearth merged commit 4a8cb11 into master Jan 12, 2020
@Manishearth Manishearth deleted the bits branch January 12, 2020 06:54
@Manishearth Manishearth mentioned this pull request Jan 12, 2020
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.

Potentially store ScriptExtension as a set of bitfields
1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy