Skip to content

baseline: Return zero gas when instruction checks fail - #1791

Open
chfast wants to merge 1 commit into
evm/gas-charge-wrap-clangfrom
baseline/zero-gas-on-failed-checks
Open

chfast wants to merge 1 commit into
evm/gas-charge-wrap-clangfrom
baseline/zero-gas-on-failed-checks

Conversation

@chfast

@chfast chfast commented Oct 28, 2026

Copy link
Copy Markdown
Member

An exceptional halt consumes all gas, so the gas left is not needed when the stack or gas check fails. Returning it made Clang keep two copies of the gas counter, because a failed stack check returns the gas before the charge and a failed gas check returns it after.

Clang 21 executes another 1% fewer instructions in the main benchmarks and 5% fewer in the micro ones (about 28% in the JUMPDEST ones). With GCC 16 this also removes the extra instructions added by #1564.

The whole series, over master: Clang 21 executes about 7% fewer instructions in the main benchmarks and 12% fewer in the micro ones, GCC 16 the same number. Cycles stay within the noise with both.

Stacked on #1790.

An exceptional halt consumes all gas, so the gas left is not needed when
the stack or gas check fails. Returning it made Clang keep two copies of
the gas counter, because a failed stack check returns the gas before the
charge and a failed gas check returns it after.
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.24%. Comparing base (a5c2539) to head (b3b530e).

Additional details and impacted files
@@                    Coverage Diff                     @@
##           evm/gas-charge-wrap-clang    #1791   +/-   ##
==========================================================
  Coverage                      98.24%   98.24%           
==========================================================
  Files                            187      187           
  Lines                          17191    17192    +1     
  Branches                        3921     3921           
==========================================================
+ Hits                           16889    16890    +1     
  Misses                           233      233           
  Partials                          69       69           
Flag Coverage Δ
eest-develop-gmp 26.99% <100.00%> (+<0.01%) ⬆️
eest-legacy 17.28% <100.00%> (+<0.01%) ⬆️
eest-libsecp256k1 29.15% <100.00%> (+<0.01%) ⬆️
eest-stable 84.23% <100.00%> (+<0.01%) ⬆️
evmone-unittests 94.11% <100.00%> (+<0.01%) ⬆️
riscv64 94.83% <100.00%> (+<0.01%) ⬆️

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

Components Coverage Δ
core 96.63% <100.00%> (+<0.01%) ⬆️
tooling 94.87% <ø> (ø)
tests 99.82% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone/baseline_execution.cpp 97.65% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will regress 3 benchmarks

1 warning

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 13 improved benchmarks
❌ 3 regressed benchmarks
✅ 883 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_block_context_ops[fork_Osaka-blockchain_test-opcode_BLOBBASEFEE-benchmark-gas-value_1M] 18.7 ms 19 ms -1.65%
❌ test_block_context_ops[fork_Osaka-blockchain_test-opcode_COINBASE-benchmark-gas-value_1M] 23.2 ms 23.5 ms -1.27%
❌ test_block_context_ops[fork_Osaka-blockchain_test-opcode_TIMESTAMP-benchmark-gas-value_1M] 13.6 ms 13.8 ms -1.02%
⚡ test_push[fork_Osaka-blockchain_test-opcode_PUSH4-benchmark-gas-value_1M] 12.1 ms 10.7 ms +13.65%
⚡ test_gas_op[fork_Osaka-blockchain_test-benchmark-gas-value_1M] 12.6 ms 12.3 ms +2.42%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP2-benchmark-gas-value_1M] 9.7 ms 9.5 ms +2.1%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP8-benchmark-gas-value_1M] 9.7 ms 9.5 ms +1.99%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP9-benchmark-gas-value_1M] 9.7 ms 9.6 ms +1.86%
⚡ baseline/analyse/main/sha1_shifts 11.5 µs 11.3 µs +1.72%
⚡ test_push[fork_Osaka-blockchain_test-opcode_PUSH0-benchmark-gas-value_1M] 13.2 ms 13 ms +1.47%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP14-benchmark-gas-value_1M] 9.6 ms 9.5 ms +1.44%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP13-benchmark-gas-value_1M] 9.7 ms 9.6 ms +1.26%
⚡ test_pc_op[fork_Osaka-blockchain_test-benchmark-gas-value_1M] 13.2 ms 13 ms +1.15%
⚡ test_msize[fork_Osaka-blockchain_test-mem_size_1-benchmark-gas-value_1M] 13.5 ms 13.4 ms +1.15%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP16-benchmark-gas-value_1M] 9.8 ms 9.7 ms +1.11%
⚡ test_dup[fork_Osaka-blockchain_test-opcode_DUP1-benchmark-gas-value_1M] 9.6 ms 9.5 ms +1.05%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing baseline/zero-gas-on-failed-checks (b3b530e) with evm/gas-charge-wrap-clang (a5c2539)

Open in CodSpeed

This branch has not been deployed

No deployments
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.

1 participant