Skip to content

test: Fix the modarith benchmarks measuring dead code - #1663

Merged
chfast merged 1 commit into
masterfrom
test/modarith-bench-dce
Aug 19, 2026
Merged

test: Fix the modarith benchmarks measuring dead code#1663
chfast merged 1 commit into
masterfrom
test/modarith-bench-dce

Conversation

@chfast

@chfast chfast commented Aug 17, 2026

Copy link
Copy Markdown
Member

The benchmarked values are unused after the loop, so the compiler is free to delete the loop body.
For addition and subtraction it does exactly that, and the benchmarks have been reporting the cost
of an empty loop. Consuming the final values with DoNotOptimize() keeps the chain alive without
adding anything inside the loop.

ns per operation before after
modarith_add<bn254> 0.140 2.47
modarith_sub<bn254> 0.127 2.24
modarith_mul<bn254> 32.7 31.6

Only the multiplication was surviving, and only because its call was not inlined — which makes it
fragile rather than correct. It is the reason this comes first: with a compile-time modulus the
multiplication does get inlined, and would then be eliminated too.

@codspeed-hq

codspeed-hq Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 129 untouched benchmarks


Comparing test/modarith-bench-dce (8b11ea6) with master (325eb1f)

Open in CodSpeed

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.72%. Comparing base (325eb1f) to head (8b11ea6).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1663   +/-   ##
=======================================
  Coverage   97.72%   97.72%           
=======================================
  Files         171      171           
  Lines       15636    15636           
  Branches     3616     3616           
=======================================
  Hits        15280    15280           
  Misses        269      269           
  Partials       87       87           
Flag Coverage Δ
eest-develop 88.60% <ø> (ø)
eest-develop-gmp 26.56% <ø> (ø)
eest-legacy 17.14% <ø> (ø)
eest-libsecp256k1 28.83% <ø> (ø)
eest-stable 88.60% <ø> (ø)
evmone-unittests 93.44% <ø> (ø)

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

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

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

Prevents compilers from eliminating modular arithmetic benchmark loops.

Changes:

  • Consumes final addition, subtraction, and multiplication results with DoNotOptimize().

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The benchmarked values are unused after the loop, so the compiler is
free to delete the loop body: the addition and subtraction benchmarks
measured an empty loop. The multiplication survived only because its
call was not inlined. Consume the final values with DoNotOptimize.
@chfast
chfast force-pushed the test/modarith-bench-dce branch from 34ee143 to 8b11ea6 Compare August 18, 2026 21:25
@chfast
chfast merged commit 9344010 into master Aug 19, 2026
25 checks passed
@chfast
chfast deleted the test/modarith-bench-dce branch August 19, 2026 10:36
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