Build the cryptography code with -O1 in Debug configurations - #1619
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1619 +/- ##
=======================================
Coverage 97.46% 97.46%
=======================================
Files 170 170
Lines 15402 15402
Branches 3604 3604
=======================================
Hits 15012 15012
Misses 282 282
Partials 108 108
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
chfast
force-pushed
the
crypto/precompiles-debug-opt
branch
from
August 8, 2026 12:19
bb41a58 to
034eb02
Compare
The 256-bit field arithmetic behind the precompiles is unusable when it is not optimized: a secp256k1 signature recovery takes ~16 ms at -O0 against ~0.3 ms at -O1, a factor of 48. Nothing steps into this code with a debugger, but every Debug and sanitizer run of the test suites pays for it, and the tests that recover a sender per transaction pay it thousands of times. The Cancun state tests, 2339 of them, drop from 274 s to 239 s of CPU time in a Debug build once this arithmetic is optimized. Raise the target to -O1 there. The option is appended after the configuration's own flags, so it wins for Debug, which sets no -O at all, and the generator expression leaves the optimized configurations untouched. The gcc-latest-memcheck job already builds Debug with -O1 for the same reason.
chfast
force-pushed
the
crypto/precompiles-debug-opt
branch
from
August 8, 2026 12:25
034eb02 to
e86dc63
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves Debug-build performance of the precompiles’ cryptography implementation by enabling -O1 optimizations for the evmone_precompiles target when using GCC/Clang-family compilers, avoiding the large slowdown seen at -O0.
Changes:
- Add a Debug-only
-O1compile option forevmone_precompileson GNU/Clang/AppleClang via a generator expression.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+46
to
+50
| # Enable optimizations in the cryptography code also in Debug builds, otherwise it is very slow. | ||
| target_compile_options( | ||
| evmone_precompiles PRIVATE | ||
| $<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:GNU,Clang,AppleClang>>:-O1> | ||
| ) |
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.
The 256-bit field arithmetic behind the precompiles is unusable when it is not optimized: a secp256k1 signature recovery takes ~16 ms at
-O0against ~0.3 ms at-O1, a factor of 48. Nothing steps into this code with a debugger, but every Debug and sanitizer run of the test suites pays for it, and the tests that recover a sender per transaction pay it thousands of times.Measured on the Cancun state tests (2339 cases, one signature recovery each) in a Debug build, user CPU time:
-O0-O1The 34.7 s saved is 14.8 ms per case, matching the ~16 ms per recovery measured directly.
The option is appended after the configuration's own flags, so it wins for Debug, which sets no
-Oat all, and the generator expression leaves the optimized configurations untouched. It is scoped to theevmone_precompilestarget alone:lib/evmoneand every other target keep their configuration's flags unchanged. Thegcc-latest-memcheckjob already builds Debug with-O1for the same reason.