Repository navigation
feat(bench): split the beacon import's stf phase into steps, classes and resources - #756
MegaRedHand wants to merge 1 commit into
Conversation
…and resources
The import replay reported `stf` as one number, which is most of a mainnet
block's import but does not say which step of the transition to attack, nor
whether an epoch-crossing block, a block after skipped slots and an ordinary
block differ. The beacon STF had no internal timing at all.
lean_beacon_stf_phase_seconds{context,phase} is observed around the steps of
the transition: process_slots (excluding epoch work), process_epoch, the block
signature, header (including the body hash it commits to), randao, eth1 data,
execution payload (gloas: parent payload, withdrawals, bid), each operation
list, the sync aggregate and the post-state root check. One Instant pair per
step, none per attestation; an empty list observes nothing. The phase list is
generated with the enum that the code observes through, so the two cannot
disagree.
The epoch precompute worker runs process_epoch on another thread while an
import runs, and the replay reads the histogram before and after each block, so
one series would charge the worker to whichever block was importing. The series
is split by a context label instead: only fork_choice's transition_block sets
`import` (a thread-local guard, since the steps are observed deep inside the
per-fork block processing), and every other caller writes `other`. The replay
reads only `import`.
The replay report (schema_version 2) gains per block: the STF steps, the stf
time outside any step, a class (epoch_boundary, after_skip, ordinary), process
CPU seconds and RSS; and per run: p95 and p99, a per-class summary and the
deltas of the cache lookup counters, so precompute hit rates appear in it.
Consensus behavior is unchanged.
🤖 Claude Code ReviewReview of PR 756: split the beacon import's STF phase into steps, classes and resourcesThe PR is benchmark-only plus one metric label, so there's no consensus-path risk. I read the diff and the surrounding Points worth addressing
Minor
VerdictNo correctness or security issues found. I'd approve after considering Point 1 (a guard test for the thread-local assumption) and Point 2 (warn on a non-trivial overshoot). Automated review by Claude (Anthropic) · sonnet · custom prompt |
🤖 Codex Code ReviewI’m done reading. Here are the review findings I’d leave on the PR.
Overall this looks solid: the STF phase split, per-thread import context, and replay-side cache/resource reporting are thoughtfully designed and don’t appear to disturb consensus behavior. If you want, I can turn this into ready-to-post GitHub review comments with one comment per file/line. Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🤖 Kimi Code ReviewI'll review this PR which adds detailed beacon state transition phase timing, resource monitoring, and enhanced reporting to the benchmark import replay. Let me analyze each component. Overall AssessmentThis is a well-structured benchmarking/metrics PR with generally good code quality. The core logic around STF phase timing, resource monitoring, and report generation is sound. However, I've identified several issues ranging from minor correctness concerns to potential bugs in edge cases. Detailed Findings1. Potential Integer Overflow in
|
| Priority | Item | File | Line(s) | Issue |
|---|---|---|---|---|
| Low | 1 | process.rs |
71 | VmRSS parsing too strict |
| Low | 2 | replay.rs |
257-260 | max(0.0) silent clamp |
| Info | 3 | metrics.rs |
287-301 | ImportContextGuard Send semantics |
| Low | 4 | metrics.rs |
393-413 | Loop overhead in try_for_each_timed |
| — | 5 | block.rs |
141-157 | Correctly no sync aggregate in phase0 |
| — | 6 | gloas.rs |
111-125 |
Automated review by Kimi (Moonshot AI) · kimi-k2.6 · custom prompt
…and resources (#756) The import replay reported `stf` as one number, which is most of a mainnet block's import but does not say which step of the transition to attack, nor whether an epoch-crossing block, a block after skipped slots and an ordinary block differ. The beacon STF had no internal timing at all. lean_beacon_stf_phase_seconds{context,phase} is observed around the steps of the transition: process_slots (excluding epoch work), process_epoch, the block signature, header (including the body hash it commits to), randao, eth1 data, execution payload (gloas: parent payload, withdrawals, bid), each operation list, the sync aggregate and the post-state root check. One Instant pair per step, none per attestation; an empty list observes nothing. The phase list is generated with the enum that the code observes through, so the two cannot disagree. The epoch precompute worker runs process_epoch on another thread while an import runs, and the replay reads the histogram before and after each block, so one series would charge the worker to whichever block was importing. The series is split by a context label instead: only fork_choice's transition_block sets `import` (a thread-local guard, since the steps are observed deep inside the per-fork block processing), and every other caller writes `other`. The replay reads only `import`. The replay report (schema_version 2) gains per block: the STF steps, the stf time outside any step, a class (epoch_boundary, after_skip, ordinary), process CPU seconds and RSS; and per run: p95 and p99, a per-class summary and the deltas of the cache lookup counters, so precompute hit rates appear in it. Consensus behavior is unchanged. Adapted onto nightly: block processing now defers every signature but the proposer's into one `SignatureBatch` (#738), so the old inline checks the timers wrapped no longer exist. Every call site keeps nightly's `signatures` argument and order, with the timers wrapped around the same steps as before; the proposer signature stays immediate and is still timed as `block_signature`. A new phase `batch_signatures` times `SignatureBatch::verify`, the one random-weight check of everything the steps deferred, so the verify cost that used to sit inside `randao`, the operation lists and `sync_aggregate` is now its own series. Those phases now cover building the signature sets and the state changes, not verification, and docs/metrics.md and docs/benchmarking.md say so. The phase is declared in the `StfPhase` enum, so the label list stays generated from it. replay.rs keeps both `--warm-committee-sums` (warm-up before the timers start) and the report changes; the report test for warm_committee_sums gets the new `Caches` argument. Verdicts, order and errors are nightly's. docs/benchmarking.md keeps #755's paragraph on the overlapped transition ahead of this section. Cherry-picked from perf/beacon-stf-phase-timing at c891134, adapted in 5c385e084.
|
Checks on this branch (based on
|
🗒️ Description / Motivation
The import replay reported
stfas one number. That is most of a mainnet block's import, but it does not say which step of the transition to attack, nor whether an epoch-crossing block, a block after skipped slots and an ordinary block differ. The beacon STF had no internal timing at all.What Changed
crates/blockchain/state_transition/src/metrics.rs,stf/*.rs,fork_choice.rs:lean_beacon_stf_phase_seconds{context,phase}is observed around the steps of the transition:process_slots(excluding epoch work),process_epoch, the block signature, header (including the body hash it commits to), randao, eth1 data, execution payload (gloas: parent payload, withdrawals, bid), each operation list, the sync aggregate and the post-state root check. OneInstantpair per step, none per attestation; an empty list observes nothing. The phase list is generated with the enum the code observes through, so the two cannot disagree.contextlabel: the epoch precompute worker runsprocess_epochon another thread while an import runs, and the replay reads the histogram before and after each block, so one series would charge the worker to whichever block was importing. Onlyfork_choice'stransition_blocksetsimport(a thread-local guard, since the steps are observed deep inside the per-fork block processing); every other caller writesother. The replay reads onlyimport.bin/ethlambda/src/benchmark/: the replay report (schema_version2) gains per block the STF steps, the stf time outside any step, a class (epoch_boundary,after_skip,ordinary), process CPU seconds and RSS; and per run p95 and p99, a per-class summary and the deltas of the cache lookup counters, so precompute hit rates appear in it.docs/benchmarking.md,docs/metrics.md.Correctness / Behavior Guarantees
Tests Added / Run
On this branch (based on
main):cargo fmt --all -- --check,make lintandcargo test --profile release-fast -p ethlambda-state-transition -p ethlambda --lib --binsare running; results will be posted as a comment.On the adaptation of this change onto
nightly(which carries the BLS stack):cargo fmt --all -- --check: clean;make lint: cleancargo test --profile release-fast -p ethlambda-state-transition -p ethlambda-blockchain -p ethlambda-crypto --lib --bins: 649 + 292 + 47 passed, 0 failedcargo test --profile release-fast -p ethlambda --bins: 287 passed, 4 ignoredbeacon_spec_tests(mainnet, v1.7.0-beta.2):sanity/595,/attestation/356,operations/2141 passed, 0 failedNot run locally:
make test(spec suites) and the minimal-preset beacon spec tests; CI covers them.Related Issues / PRs
Part of a beacon import perf batch, each PR independent and based on
main: #752, #753, #754, #755. Overlaps: #755 also editsdocs/benchmarking.mdandfork_choice.rs(different regions); most batch PRs editdocs/metrics.md.The BLS stack (#738) moves block signature checks into a deferred batch, so whichever of the two merges second adapts the phases to it. The
nightlyadaptation does it this way: a new phasebatch_signatures(observed inSignatureBatch::verify, including the failure re-check loop);randao, the operation lists andsync_aggregatethen cover set building and state changes only;block_signatureis the proposer signature alone, which #738 still checks immediately.✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — cleanmake test(test-consensusplustest-node, atrelease-fast) — not run locally (spec suites); unit tests of the touched crates pass