Skip to content

Build the cryptography code with -O1 in Debug configurations - #1619

Merged
chfast merged 1 commit into
masterfrom
crypto/precompiles-debug-opt
Aug 8, 2026
Merged

Build the cryptography code with -O1 in Debug configurations#1619
chfast merged 1 commit into
masterfrom
crypto/precompiles-debug-opt

Conversation

@chfast

@chfast chfast commented Aug 7, 2026

Copy link
Copy Markdown
Member

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.

Measured on the Cancun state tests (2339 cases, one signature recovery each) in a Debug build, user CPU time:

precompiles time
-O0 273.6 s
-O1 238.9 s

The 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 -O at all, and the generator expression leaves the optimized configurations untouched. It is scoped to the evmone_precompiles target alone: lib/evmone and every other target keep their configuration's flags unchanged. The gcc-latest-memcheck job already builds Debug with -O1 for the same reason.

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.46%. Comparing base (d8508b9) to head (e86dc63).

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           
Flag Coverage Δ
eest-develop 88.34% <ø> (ø)
eest-develop-gmp 25.78% <ø> (ø)
eest-legacy 17.37% <ø> (ø)
eest-libsecp256k1 27.91% <ø> (ø)
eest-stable 88.30% <ø> (ø)
evmone-unittests 93.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 95.99% <ø> (ø)
tooling 90.42% <ø> (ø)
tests 99.80% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chfast
chfast force-pushed the crypto/precompiles-debug-opt branch from bb41a58 to 034eb02 Compare August 8, 2026 12:19
@chfast chfast changed the title Build the precompiles with -O1 in Debug configurations Build the cryptography code with -O1 in Debug configurations Aug 8, 2026
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
chfast force-pushed the crypto/precompiles-debug-opt branch from 034eb02 to e86dc63 Compare August 8, 2026 12:25
@chfast
chfast requested a lite review from Copilot August 8, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 -O1 compile option for evmone_precompiles on 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>
)
@chfast
chfast merged commit 8cc8e36 into master Aug 8, 2026
24 checks passed
@chfast
chfast deleted the crypto/precompiles-debug-opt branch August 8, 2026 12:58
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