8000 perf: special-case pow(2, n) with shl by DaniPopes · Pull Request #475 · recmo/uint · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf: special-case pow(2, n) with shl #475

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

DaniPopes
Copy link
Contributor
@DaniPopes DaniPopes commented May 28, 2025

Check self==2 in pow, returning 1<<exp instead of looping.

This also fixes Shl and Shr impls for Uint with Uint: the code was using limbs[0] without checking that the other limbs are 0. Extracted to #476.

@DaniPopes DaniPopes requested a review from prestwich as a code owner May 28, 2025 23:43
@DaniPopes DaniPopes force-pushed the pow-2-by-n branch 3 times, most recently from 668df59 to a203841 Compare May 29, 2025 00:29
Copy link
codspeed-hq bot commented May 29, 2025

CodSpeed Performance Report

Merging #475 will degrade performances by 23.61%

Comparing DaniPopes:pow-2-by-n (7ec9f59) with main (51f9ce6)

Summary

⚡ 3 improvements
❌ 8 regressions
✅ 242 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
log/192 11.8 ms 13.7 ms -13.65%
log/256 14.3 ms 16.2 ms -11.61%
log/384 21.1 ms 23.5 ms -10.41%
overflowing_pow/192 1.1 ms 1.4 ms -18.64%
overflowing_pow/256 2 ms 2.3 ms -14.06%
overflowing_pow/384 4.5 ms 5.1 ms -12.23%
overflowing_pow/4096 1.8 ms 2.3 ms -23.61%
overflowing_pow/64 79.4 µs 35.6 µs ×2.2
root/127/128/128 9.8 ms 5.6 ms +76.88%
root/127/192/192 16.1 ms 11.8 ms +36.85%
root/127/256/256 12.2 ms 13.8 ms -11.89%

@DaniPopes DaniPopes force-pushed the pow-2-by-n branch 3 times, most recently from 599372d to aa7bd46 Compare May 29, 2025 00:55
@prestwich prestwich enabled auto-merge May 29, 2025 14:36
@DaniPopes DaniPopes marked this pull request as draft May 29, 2025 14:37
auto-merge was automatically disabled May 29, 2025 14:37

Pull request was converted to draft

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
0