Skip to content

feat(tests): add test for worst-case prefetcher performance#2657

Merged
LouisTsai-Csie merged 16 commits intoethereum:forks/amsterdamfrom
nerolation:toni/trick-prefetch
Apr 15, 2026
Merged

feat(tests): add test for worst-case prefetcher performance#2657
LouisTsai-Csie merged 16 commits intoethereum:forks/amsterdamfrom
nerolation:toni/trick-prefetch

Conversation

@nerolation
Copy link
Copy Markdown
Contributor

🗒️ Description

Add test_sload_bloated_prefetch_miss benchmark that defeats client prefetchers by making each transaction's SLOAD range depend on state written by its predecessor. A minimal first tx writes an offset to slot 0 via calldata; subsequent max-gas txs read the previous offset, SLOAD from it, and write a new offset for the next tx.

🔗 Related Issues or PRs

N/A.

✅ Checklist

Cute Animal Picture

image

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.25%. Comparing base (a48e0b3) to head (f7d22f3).
⚠️ Report is 7 commits behind head on forks/amsterdam.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           forks/amsterdam    #2657      +/-   ##
===================================================
+ Coverage            86.24%   86.25%   +0.01%     
===================================================
  Files                  599      599              
  Lines                36984    37032      +48     
  Branches              3795     3795              
===================================================
+ Hits                 31895    31943      +48     
  Misses                4525     4525              
  Partials               564      564              
Flag Coverage Δ
unittests 86.25% <ø> (+0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

Some comments 😄 👍

Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py
Copy link
Copy Markdown
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

I somehow did not see that this approach solves the same problem but with less gas (I did not realize this also tricks the prefetcher). One final comment for verification.

Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py
Copy link
Copy Markdown
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks a lot!!

Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Copy link
Copy Markdown
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

I am having troubles filling these payloads and need to investigate more (can´t seem to retract my previous review 🤔 )

EDIT; this worked

Copy link
Copy Markdown
Collaborator

@LouisTsai-Csie LouisTsai-Csie left a comment

Choose a reason for hiding this comment

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

Leave some style suggestion comment, please take a look!

Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
nerolation and others added 6 commits April 13, 2026 11:02
Co-authored-by: 蔡佳誠 Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
Co-authored-by: 蔡佳誠 Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
Co-authored-by: 蔡佳誠 Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
Co-authored-by: 蔡佳誠 Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
Co-authored-by: 蔡佳誠 Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
tx_gas = min(gas_available, tx_gas_limit)
target = pre.deploy_contract(
code=runtime_code,
storage=Storage(storage_data),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will likely have the problem that either this code will not fit in initcode, or the predeploy code to execute will use more than 2**24 gas. @LouisTsai-Csie we should likely create a general helper here for the predeploy in execute

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We already have this helper, it is not clear though:

In the test_sstore_variants benchmark, we delegate to this helper then initialize the storage, later execute the benchmark code. This would not go out of gas, but not sure if it would take too much time or not.

@jochem-brouwer
Copy link
Copy Markdown
Member

Here is fixture output of the sload_bloated_multi_contract. I'll check this soon, wanted to dump this progress. The good point here is that the fixture fills succesfully so it passes any checks made on the output (BAL checks). Will do similar to the other test also.

sload_bloated_multi_contract.json

Copy link
Copy Markdown
Collaborator

@LouisTsai-Csie LouisTsai-Csie left a comment

Choose a reason for hiding this comment

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

Thanks for the update, i did a final check, after these changes let's merge.

Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
Comment thread tests/benchmark/stateful/bloatnet/test_single_opcode.py Outdated
nerolation and others added 3 commits April 14, 2026 09:54
Co-authored-by: 蔡佳誠 Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
Co-authored-by: 蔡佳誠 Louis Tsai <72684086+LouisTsai-Csie@users.noreply.github.com>
@nerolation
Copy link
Copy Markdown
Contributor Author

Everything addressed. Ready for one last review!

Copy link
Copy Markdown
Collaborator

@LouisTsai-Csie LouisTsai-Csie left a comment

Choose a reason for hiding this comment

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

Thank you! I will merge it for now, and refactor in PR #2672, as the current storage initialization would break at high gas configuration.

@LouisTsai-Csie LouisTsai-Csie merged commit 132c09d into ethereum:forks/amsterdam Apr 15, 2026
18 checks passed
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.

4 participants