perf: Optimize UUID hex parsing and formatting#894
Merged
Conversation
KodrAus
approved these changes
Jul 11, 2026
KodrAus
left a comment
Member
There was a problem hiding this comment.
Thanks for working on this @geeknoid! We previously had looked at manually vectorized routines but didn't keep them here just because I didn't want to complicate the project or our CI too much to maintain them or try port them across ISAs. If this autovectorizes nicely on x86 and ARM then that's a big win.
| [dev-dependencies.rustversion] | ||
| version = "1" | ||
|
|
||
| [target.'cfg(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))))'.dev-dependencies.gungraun] |
Member
There was a problem hiding this comment.
I wasn't familiar with gungraun, it looks interesting 👀
Author
There was a problem hiding this comment.
Yes, it's a game changer. You get deterministic benchmark results instantaneously.
Member
|
Looks like we'll need to cfg |
Author
|
@KodrAus The WASM build issue should be fixed. I don't know how to trigger your CI though... |
Replace the byte-at-a-time lookup-table hex encode/decode in the parser
and formatter with branchless arithmetic. Both stay const-evaluable and
free of unsafe, and the loops now auto-vectorize (e.g. SSE2 on x86_64,
NEON on aarch64), roughly halving instruction counts on the hot paths.
Benchmarks below compare before/after using the gungraun (Callgrind
instruction counts) and libtest (wall-clock) harnesses added here.
Benchmark Instructions Time (ns/iter)
before after before after
------------------------ ------- ----- ------ -----
parse_random 261 112 40 14
parse_nil 261 113 40 14
parse_random_hyphenated 271 134 37 29
parse_nil_hyphenated 271 134 37 29
parse_urn 290 152 38 30
encode_simple 131 61 12.4 0.7
encode_hyphen 139 81 6.6 1.8
encode_urn 152 127 7.1 2.0
Display (simple) 296 236 25.0 16.5
Display (hyphenated) 304 252 26 22
Display (urn) 303 254 29 27
kodiakhq Bot
pushed a commit
to pdylanross/fatigue
that referenced
this pull request
Jul 13, 2026
Bumps uuid from 1.23.4 to 1.23.5. Release notes Sourced from uuid's releases. v1.23.5 What's Changed doc: Fix broken link by @frostyplanet in uuid-rs/uuid#891 perf: Optimize UUID hex parsing and formatting by @geeknoid in uuid-rs/uuid#894 Prepare for 1.23.5 release by @KodrAus in uuid-rs/uuid#895 New Contributors @geeknoid made their first contribution in uuid-rs/uuid#894 Full Changelog: uuid-rs/uuid@v1.23.4...v1.23.5 Commits 5dc6b3d Merge pull request #895 from uuid-rs/cargo/v1.23.5 5a7dfe5 prepare for 1.23.5 release 9b4bfc8 Merge pull request #894 from geeknoid/main 5acc5a5 perf: Optimize UUID hex parsing and formatting 1e5d867 Merge pull request #891 from frostyplanet/doc 49310f0 doc: Fix broken link See full diff in compare view Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase. Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: @dependabot rebase will rebase this PR @dependabot recreate will recreate this PR, overwriting any edits that have been made to it @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
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.
Replace the byte-at-a-time lookup-table hex encode/decode in the parser and formatter with branchless arithmetic. Both stay const-evaluable and free of unsafe, and the loops now auto-vectorize (e.g. SSE2 on x86_64, NEON on aarch64), roughly halving instruction counts on the hot paths.
Benchmarks below compare before/after using the gungraun (Callgrind instruction counts) and libtest (wall-clock) harnesses added here.