Repository navigation
secp256k1: Select arch-specific field backend. - #3758
Merged
davecgh merged 2 commits intoNov 20, 2026
Merged
Conversation
davecgh
force-pushed
the
secp256k1_select_backend_per_arch
branch
2 times, most recently
from
July 30, 2026 10:39
b1c0854 to
50b2de4
Compare
jholdstock
reviewed
Jul 31, 2026
davecgh
force-pushed
the
secp256k1_select_backend_per_arch
branch
from
July 31, 2026 06:57
50b2de4 to
61bbf6b
Compare
jholdstock
approved these changes
Aug 1, 2026
dcr-approvals-proxy
approved these changes
Nov 20, 2026
This modifies the field wrapper to select an architecture-specific
backend at compile time.
This is distinct from the additional architecture-specific optimizations
the backend implementations perform at run time.
Comparison of relevant operations for 32-bit platforms:
```
$ {before,after}_x86.txt
name old time/op new time/op delta
---------------------------------------------------------------------------------
AddNonConst/Z1AndZ2EqualsOne 779ns ± 3% 781ns ± 8% ~ (p=0.353 n=10+10)
AddNonConst/Z1EqualsZ2 882ns ± 5% 881ns ± 4% ~ (p=0.031 n=9+9)
AddNonConst/Z2EqualsOne 1.30µs ± 1% 1.31µs ± 1% ~ (p=0.008 n=8+9)
AddNonConst/Generic 1.81µs ± 1% 1.82µs ± 1% ~ (p=0.002 n=9+10)
DoubleNonConst/ZEqualsOne 682ns ± 3% 682ns ± 2% ~ (p=0.853 n=10+10)
DoubleNonConst/Generic 778ns ± 1% 778ns ± 2% ~ (p=0.955 n=10+10)
ScalarBaseMultNonConst 40.0µs ± 2% 40.0µs ± 1% ~ (p=0.905 n=10+9)
ScalarMultNonConst 186µs ± 2% 186µs ± 1% ~ (p=0.631 n=10+10)
SigVerify 233µs ± 1% 234µs ± 4% ~ (p=0.489 n=9+9)
RecoverCompact 281µs ± 2% 282µs ± 1% ~ (p=0.218 n=10+10)
```
Comparison of relevant operations for 64-bit platforms:
```
$ benchstat {before,after}_x64.txt
name old time/op new time/op delta
------------------------------------------------------------------------------------
AddNonConst/Z1AndZ2EqualsOne 367ns ± 3% 176ns ± 3% -52.15% (p=0.000 n=8+9)
AddNonConst/Z1EqualsZ2 403ns ± 1% 147ns ± 2% -63.48% (p=0.000 n=9+9)
AddNonConst/Z2EqualsOne 624ns ± 1% 248ns ± 2% -60.32% (p=0.000 n=8+10)
AddNonConst/Generic 871ns ± 1% 299ns ± 1% -65.64% (p=0.000 n=10+10)
DoubleNonConst/ZEqualsOne 298ns ± 2% 165ns ± 1% -44.69% (p=0.000 n=10+10)
DoubleNonConst/Generic 345ns ± 1% 171ns ± 1% -50.27% (p=0.000 n=10+9)
ScalarBaseMultNonConst 19.0µs ± 1% 7.6µs ± 1% -60.09% (p=0.000 n=8+10)
ScalarMultNonConst 85.3µs ± 2% 36.8µs ± 1% -56.83% (p=0.000 n=9+10)
SigVerify 107µs ± 2% 47µs ± 1% -56.63% (p=0.000 n=8+10)
RecoverCompact 125µs ± 1% 53µs ± 1% -57.24% (p=0.000 n=9+8)
```
As expected, the 32-bit results are effectively unchanged because those
architectures continue to the existing backend. However, as shown,
64-bit benefits from significant performance enhancements.
Also, remove repeated content from doc.go since all all doc interfaces nowadays show the `README.md` too.
davecgh
force-pushed
the
secp256k1_select_backend_per_arch
branch
from
November 20, 2026 07:42
61bbf6b to
3cb3bb7
Compare
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.
This modifies the field wrapper to choose an architecture-specific backend at compile time.
This is distinct from the additional architecture-specific optimizations the backend implementations choose at run time.
As expected, the 32-bit results do not change because it continues to use the same backend. However, as shown below, 64-bit benefits from significant performance enhancements.
Comparison of relevant operations for 32-bit platforms:
Comparison of relevant operations for 64-bit platforms: