Skip to content

core: add code read statistics#33442

Merged
rjl493456442 merged 1 commit intoethereum:masterfrom
rjl493456442:add-code-read
Dec 18, 2025
Merged

core: add code read statistics#33442
rjl493456442 merged 1 commit intoethereum:masterfrom
rjl493456442:add-code-read

Conversation

@rjl493456442
Copy link
Copy Markdown
Member

@rjl493456442 rjl493456442 commented Dec 18, 2025

This PR adds the code read statistics and exposes them via the metrics and slow block report.

INFO [12-18|07:45:25.098] ########## SLOW BLOCK #########
INFO [12-18|07:45:25.098] Block: 24038081 (0xcf0c89cc97026c89d98f60353d98a8b9459fa8635573152d240057d75473a7cb) txs: 390, mgasps: 428.54, elapsed: 97.611ms
INFO [12-18|07:45:25.098] EVM execution: 73.163ms
INFO [12-18|07:45:25.098] Validation: 2.634ms
INFO [12-18|07:45:25.098] State read: 5.967ms
INFO [12-18|07:45:25.098]     Account read: 2.201ms(1086)
INFO [12-18|07:45:25.098]     Storage read: 3.463ms(2512)
INFO [12-18|07:45:25.098] "    Code read: 302.534µs(467)"
INFO [12-18|07:45:25.098] State hash: 10.903ms
INFO [12-18|07:45:25.098]     Account hash: 4.110ms
INFO [12-18|07:45:25.098]     Storage hash: 3.279ms
INFO [12-18|07:45:25.098]     Trie commit: 3.513ms
INFO [12-18|07:45:25.098] DB write: 4.882ms
INFO [12-18|07:45:25.098]     State write: 3.119ms
INFO [12-18|07:45:25.098]     Block write: 1.762ms
INFO [12-18|07:45:25.098] Reader statistics
INFO [12-18|07:45:25.098] account: hit: 1057, miss: 29, rate: 97.33
INFO [12-18|07:45:25.098] storage: hit: 2405, miss: 107, rate: 95.74
INFO [12-18|07:45:25.098] ##############################

Copy link
Copy Markdown
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

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

sgtm

@rjl493456442 rjl493456442 added this to the 1.16.8 milestone Dec 18, 2025
@rjl493456442 rjl493456442 merged commit ffe9dc9 into ethereum:master Dec 18, 2025
15 of 19 checks passed
@jochem-brouwer
Copy link
Copy Markdown
Member

Naive question, but this adds these measurements to all execution, so this will somewhat impact the execution time on the negative side, right? Even if I don't want to use these code read statistics ever, it will still (?) spend a tiny amount of time on this. If I want maximum performance, then I would not want this. Or, does the execution at some point "know" this extra logic is not necessary and will not perform these operations while executing?

@jwasinger
Copy link
Copy Markdown
Contributor

I don't think the extra overhead of capturing a timestamp for before/after every code read would be measurable in almost any circumstance.

CPerezz added a commit to CPerezz/go-ethereum that referenced this pull request Jan 3, 2026
This extends the execution statistics infrastructure from ethereum#33442 with:

- Code cache hit/miss tracking (completing parity with account/storage)
- Code bytes read metric for I/O volume analysis
- Unique state access metrics (accounts, storage slots, contracts)

The slow block log now shows:

    Code read: 626ns(4, 1.07 KiB)

    Unique state access:
        Accounts: 6
        Storage slots: 11
        Contracts executed: 4

    Reader statistics
    account: hit: 4, miss: 6, rate: 40.00
    storage: hit: 0, miss: 11, rate: 0.00
    code: hit: 4, miss: 0, rate: 100.00
CPerezz added a commit to CPerezz/go-ethereum that referenced this pull request Jan 3, 2026
This extends the execution statistics infrastructure from ethereum#33442 with:

- Code cache hit/miss tracking (completing parity with account/storage)
- Code bytes read metric for I/O volume analysis
- Unique state access metrics (accounts, storage slots, contracts)

The slow block log now shows:

    Code read: 626ns(4, 1.07 KiB)

    Unique state access:
        Accounts: 6
        Storage slots: 11
        Contracts executed: 4

    Reader statistics
    account: hit: 4, miss: 6, rate: 40.00
    storage: hit: 0, miss: 11, rate: 0.00
    code: hit: 4, miss: 0, rate: 100.00
CPerezz added a commit to CPerezz/go-ethereum that referenced this pull request Jan 13, 2026
This extends the execution statistics infrastructure from ethereum#33442 with:

- Code cache hit/miss tracking (completing parity with account/storage)
- Code bytes read metric for I/O volume analysis
- Unique state access metrics (accounts, storage slots, contracts)

The slow block log now shows:

    Code read: 626ns(4, 1.07 KiB)

    Unique state access:
        Accounts: 6
        Storage slots: 11
        Contracts executed: 4

    Reader statistics
    account: hit: 4, miss: 6, rate: 40.00
    storage: hit: 0, miss: 11, rate: 0.00
    code: hit: 4, miss: 0, rate: 100.00
weiihann pushed a commit to weiihann/go-ethereum that referenced this pull request Jan 14, 2026
weiihann pushed a commit to weiihann/go-ethereum that referenced this pull request Jan 16, 2026
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