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

uint256: optimize AddMod #165

Merged
merged 1 commit into from
May 10, 2024
Merged

uint256: optimize AddMod #165

merged 1 commit into from
May 10, 2024

Conversation

AaronChen0
Copy link
Contributor

Test

go test ./...
ok  	github.com/holiman/uint256	1.367s

Benchmark

goos: linux
goarch: amd64
pkg: github.com/holiman/uint256
cpu: AMD Ryzen 7 7735H with Radeon Graphics         
                         │     old     │                 new                 │
                         │   sec/op    │   sec/op     vs base                │
AddMod/small/uint256-16    6.292n ± 1%   6.309n ± 1%        ~ (p=0.123 n=10)
AddMod/mod64/uint256-16    10.07n ± 1%   10.02n ± 1%   -0.55% (p=0.049 n=10)
AddMod/mod128/uint256-16   19.14n ± 1%   19.16n ± 1%        ~ (p=0.271 n=10)
AddMod/mod192/uint256-16   20.88n ± 2%   21.09n ± 1%   +1.03% (p=0.050 n=10)
AddMod/mod256/uint256-16   9.728n ± 2%   6.460n ± 1%  -33.59% (p=0.000 n=10)
AddMod/small/big-16        25.80n ± 0%   25.85n ± 0%        ~ (p=0.071 n=10)
AddMod/mod64/big-16        30.18n ± 1%   30.11n ± 0%        ~ (p=0.224 n=10)
AddMod/mod128/big-16       67.25n ± 1%   68.10n ± 0%   +1.26% (p=0.000 n=10)
AddMod/mod192/big-16       68.95n ± 0%   69.28n ± 0%   +0.47% (p=0.005 n=10)
AddMod/mod256/big-16       68.94n ± 1%   69.47n ± 0%   +0.76% (p=0.005 n=10)
geomean                    23.92n        23.04n        -3.69%

Copy link

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (09331ab) to head (0b682e9).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #165   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines         1628      1626    -2     
=========================================
- Hits          1628      1626    -2     

@holiman
Copy link
Owner

holiman commented May 10, 2024

Can confirm:

[user@work uint256]$ benchstat addmod.1 addmod.2
name                     old time/op  new time/op  delta
AddMod/small/uint256-8   21.0ns ±44%  17.0ns ±43%     ~     (p=0.052 n=10+10)
AddMod/mod64/uint256-8   28.6ns ±36%  26.6ns ±44%     ~     (p=0.481 n=10+10)
AddMod/mod128/uint256-8  56.1ns ±43%  53.7ns ±49%     ~     (p=0.810 n=10+10)
AddMod/mod192/uint256-8  62.0ns ±44%  62.2ns ±44%     ~     (p=0.971 n=10+10)
AddMod/mod256/uint256-8  25.4ns ±25%  12.0ns ±44%  -52.74%  (p=0.000 n=10+9)

Neat!

Copy link
Owner

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@holiman holiman merged commit 34f0760 into holiman:master May 10, 2024
6 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.

2 participants