Skip to content

fix(test-benchmark): benchmark MCOPY with overlapping ranges - #4122

Open
chfast wants to merge 1 commit into
ethereum:forks/bogotafrom
chfast:benchmarks/mcopy-src-dst
Open

chfast wants to merge 1 commit into
ethereum:forks/bogotafrom
chfast:benchmarks/mcopy-src-dst

Conversation

@chfast

@chfast chfast commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Description

Every test_mcopy case copied a range onto itself: MCOPY(x, x, n) with x = 0 (fixed_src_dst, repricing) or GAS % 7. Copy to one byte above the source instead (MCOPY(2, 1, n)), so the ranges overlap and both are unaligned.

Also drop the mem_size parameter, which only expands memory once (larger memory did not make the copy slower in geth, evmone or revm), the GAS % 7 offsets, and the 256-byte copy. The MCOPY cases go from 48 to 3 per fork; all 3 are repricing (was 24).

The kept sizes: 0 copies nothing, so it measures the base cost alone; 32 is the largest copy at the one-word price; 1024 checks the per-word cost on a long copy. The longer the copy, the more gas per second it runs, so 256 was never the worst case.

MGas/s, old fixed_src_dst_True-mem_size_0 → new, Osaka (AMD 5950X; wall clock of a 500M gas block minus a 1M gas block, best of 3; Nethermind with 5000M; Besu by its own block timer, local build):

copy size geth evmone erigon revm besu nethermind
0 236 → 235 1872 → 1837 403 → 398 1238 → 1196 215 → 213 1196 → 1126
32 274 → 248 2085 → 1982 485 → 463 1287 → 1233 190 → 195 779 → 570
1024 1992 → 1520 12352 → 6754 3092 → 2500 8715 → 5254 398 → 397 4604 → 3369

Other layouts (disjoint, overlapping by 1 byte, destination below the source, other relative alignments) were within about 10% of this one at 1024 bytes in each client. At 32 and 256 bytes overlapping ranges were about 15–25% slower than disjoint ones in Nethermind.

Related Issues or PRs

ethpandaops/gas-lighting-tracker#90

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <description>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.37%. Comparing base (2d92885) to head (5628156).

Additional details and impacted files
@@              Coverage Diff              @@
##           forks/bogota    #4122   +/-   ##
=============================================
  Coverage         95.37%   95.37%           
=============================================
  Files               677      677           
  Lines             41907    41907           
  Branches           3939     3939           
=============================================
  Hits              39969    39969           
  Misses             1359     1359           
  Partials            579      579           
Flag Coverage Δ
unittests 95.36% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bt-recneps bt-recneps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Traced MCOPY(2, 1, n) through the filled loop contract, base and head fixtures differ only in mcopy.json, nothing definite to flag :)

Reviewed in 14m 48s

Every test_mcopy case copied a range onto itself: MCOPY(x, x, n) with
x = 0 or GAS % 7. Copy to one byte above the source instead, so the
ranges overlap and both are unaligned.

Drop the mem_size parameter, which only expands memory once, the
GAS % 7 offsets, and the 256-byte copy, which is never the worst case.
The MCOPY cases go from 48 to 3 per fork, all repricing (was 24).
@chfast
chfast force-pushed the benchmarks/mcopy-src-dst branch from 846cc73 to 5628156 Compare December 4, 2026 08:51

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.

2 participants