Skip to content

Medium string hashing inline(never) instead of cold#37

Merged
hoxxep merged 6 commits intomasterfrom
medium-performance-improvement
Aug 9, 2025
Merged

Medium string hashing inline(never) instead of cold#37
hoxxep merged 6 commits intomasterfrom
medium-performance-improvement

Conversation

@hoxxep
Copy link
Owner

@hoxxep hoxxep commented Aug 5, 2025

Performance improvement for strurl -4%. Spotted while optimising foldhash. Needs a full benchmarking run.

TODO:

  • Non-portable read_u64 and read_u32

@hoxxep
Copy link
Owner Author

hoxxep commented Aug 9, 2025

Results suggest 3% improvement to struuid, 5% improvement to strdate, 1.5% improvement to strenglishword and strurl.

For quality hasher, it's a much bigger improvement, as the smaller write code size seems to allow inlining the Hash::hash(str) call more often, and can improve performance by around 10-20% on various string lengths.

realworld/StrUuid/hashonly-struuid-rapidhash-q                                                                             
                        time:   [3.2958 ns 3.2980 ns 3.3003 ns]
                        change: [-12.157% -11.598% -11.182%] (p = 0.00 < 0.05)
                        Performance has improved.
realworld/StrUuid/hashonly-struuid-rapidhash-f                                                                             
                        time:   [2.4988 ns 2.5025 ns 2.5075 ns]
                        change: [-3.4689% -3.0047% -2.6492%] (p = 0.00 < 0.05)
                        Performance has improved.

realworld/StrDate/hashonly-strdate-rapidhash-q                                                                             
                        time:   [2.0761 ns 2.0795 ns 2.0832 ns]
                        change: [-12.625% -12.231% -11.893%] (p = 0.00 < 0.05)
                        Performance has improved.
realworld/StrDate/hashonly-strdate-rapidhash-f                                                                             
                        time:   [1.3631 ns 1.3648 ns 1.3668 ns]
                        change: [-5.8023% -5.6102% -5.4214%] (p = 0.00 < 0.05)
                        Performance has improved.

realworld/StrEnglishWord/hashonly-strenglishword-rapidhash-q                                                                             
                        time:   [2.1668 ns 2.1692 ns 2.1718 ns]
                        change: [-23.959% -23.245% -22.518%] (p = 0.00 < 0.05)
                        Performance has improved.
realworld/StrEnglishWord/hashonly-strenglishword-rapidhash-f                                                                             
                        time:   [1.4604 ns 1.4627 ns 1.4654 ns]
                        change: [-1.6729% -1.4254% -1.1751%] (p = 0.00 < 0.05)
                        Performance has improved.

realworld/StrUrl/hashonly-strurl-rapidhash-q                                                                             
                        time:   [5.6554 ns 5.7057 ns 5.7562 ns]
                        change: [-12.927% -11.788% -10.725%] (p = 0.00 < 0.05)
                        Performance has improved.
realworld/StrUrl/hashonly-strurl-rapidhash-f                                                                             
                        time:   [4.7906 ns 4.8248 ns 4.8587 ns]
                        change: [-2.4629% -1.5265% -0.4834%] (p = 0.00 < 0.05)
                        Change within noise threshold.

realworld/Kilobyte/hashonly-kilobyte-rapidhash-q                                                                             
                        time:   [27.642 ns 27.670 ns 27.697 ns]
                        change: [-9.9109% -9.7570% -9.6045%] (p = 0.00 < 0.05)
                        Performance has improved.
realworld/Kilobyte/hashonly-kilobyte-rapidhash-f                                                                             
                        time:   [26.783 ns 26.829 ns 26.888 ns]
                        change: [-1.3766% -1.1587% -0.9183%] (p = 0.00 < 0.05)
                        Change within noise threshold.

realworld/TenKilobyte/hashonly-tenkilobyte-rapidhash-q                                                                            
                        time:   [233.21 ns 233.75 ns 234.35 ns]
                        change: [-0.6903% -0.3787% -0.0557%] (p = 0.02 < 0.05)
                        Change within noise threshold.
realworld/TenKilobyte/hashonly-tenkilobyte-rapidhash-f                                                                            
                        time:   [232.82 ns 233.23 ns 233.65 ns]
                        change: [-0.0684% +0.2162% +0.4645%] (p = 0.10 > 0.05)
                        No change in performance detected.

@hoxxep hoxxep marked this pull request as ready for review August 9, 2025 13:33
@hoxxep hoxxep merged commit d8b725b into master Aug 9, 2025
8 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.

1 participant