Skip to content

perf: clean up div, cmp#464

Merged
prestwich merged 4 commits into
alloy-rs:mainfrom
DaniPopes:div-cleanups
May 29, 2025
Merged

perf: clean up div, cmp#464
prestwich merged 4 commits into
alloy-rs:mainfrom
DaniPopes:div-cleanups

Conversation

@DaniPopes
Copy link
Copy Markdown
Member

@DaniPopes DaniPopes commented May 21, 2025

  • Remove impossible panics and reduce size of possible panics (div by 0) from div dispatching code to make it more amenable for inlining
  • Fix cmp for slices of different lengths; improve comments

@prestwich
Copy link
Copy Markdown
Member

blocked by #461

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 26, 2025

CodSpeed Performance Report

Merging #464 will improve performances by ×2.7

Comparing DaniPopes:div-cleanups (1939083) with main (20a2367)

Summary

⚡ 21 improvements
✅ 204 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
add_mod/64 577.8 µs 238.8 µs ×2.4
div_rem/128/128 1,193.9 µs 973.9 µs +22.59%
div_rem/192/192 1.8 ms 1.4 ms +32.71%
div_rem/256/256 2 ms 1.6 ms +27.71%
div_rem/384/384 2.4 ms 2 ms +22.38%
div_rem/512/512 2.8 ms 2.4 ms +17.85%
div_rem/64/32 538 µs 201.5 µs ×2.7
div_rem/64/64 538 µs 201.5 µs ×2.7
overflowing_pow/128 622.9 µs 534.9 µs +16.45%
overflowing_pow/192 1.3 ms 1.1 ms +15.92%
overflowing_pow/256 2.2 ms 2 ms +11.47%
overflowing_pow/384 5.1 ms 4.5 ms +13.93%
overflowing_pow/4096 2.4 ms 1.7 ms +39.84%
pow/384 5.4 ms 4.8 ms +10.72%
pow/4096 2.8 ms 2.2 ms +32%
pow_mod/64 709.2 µs 641.2 µs +10.61%
reduce_mod/64 326 µs 159.5 µs ×2
root/2/64/64 2.1 ms 1.1 ms +90.54%
root/3/64/64 2.2 ms 1.2 ms +86.11%
root/5/64/64 2.2 ms 1.2 ms +81.96%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@DaniPopes DaniPopes force-pushed the div-cleanups branch 2 times, most recently from 930d323 to cb1b442 Compare May 28, 2025 00:09
@DaniPopes DaniPopes changed the title perf: clean up div perf: clean up div, cmp May 28, 2025
@DaniPopes DaniPopes marked this pull request as ready for review May 28, 2025 00:42
@DaniPopes DaniPopes requested a review from prestwich as a code owner May 28, 2025 00:42
@prestwich prestwich enabled auto-merge May 29, 2025 13:19
@prestwich prestwich merged commit 7d433a6 into alloy-rs:main May 29, 2025
19 checks passed
@DaniPopes DaniPopes deleted the div-cleanups branch May 29, 2025 14:03
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