Skip to content
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

Increase Decoder Performance With Minimal Code Change #82

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ultrabear
Copy link

After evaluating what I believe this crates goals are (being simple) I have come up with (along with the help of browsing other hex crates performance boosting methods) a minimal code change that doesn't sacrifice a lot of readability, or dip into unsafe, while still giving a noticeable speedup to the decoder.

Its possible that even simpler changes could speed up the crate, but this is the least intrusive method I have found that still produces a real performance gain (over the past few days of looking into this).

This code passes all tests, fmt, and clippy (stable rust 1.72).

Relevant benchmarks (using benches/hex.rs):

Performed on a Ryzen 2600

Before change
hex_decode              time:   [139.11 µs 139.97 µs 140.95 µs]                       

After change
hex_decode              time:   [107.11 µs 108.24 µs 109.44 µs]                       

This crate is a candidate to include #![forbid(unsafe_code)], and I recommend doing so, but that is outside of the scope of this PR.

@ultrabear ultrabear changed the title add array lookup to decoder for notieable perf boost with minimal code change Increase Decoder Performance With Minimal Code Change Sep 14, 2023
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.

None yet

1 participant