execution/commitment: record the trunk-preload duration and bytes counters - #23067
Open
lystopad wants to merge 5 commits into
Open
execution/commitment: record the trunk-preload duration and bytes counters#23067lystopad wants to merge 5 commits into
lystopad wants to merge 5 commits into
Conversation
…nters commitment_trunk_preload_duration_seconds_total and commitment_trunk_preload_bytes_total were declared in trunk_pin_metrics.go but never written, so both read 0 for the life of the process. There was no metric signal for how much work the adaptive pin controller was doing, or how long it spent doing it. Record both at the two places a preload actually runs: the initial view in promoteLocked and the per-block step in runExtensionLocked, covering the parallel and serial paths. A promote whose Run fails is rolled back, so it contributes its duration but no bytes. Tests assert both counters advance across a promote and across an extension.
AskAlexSharov
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
commitment_trunk_preload_duration_seconds_totalandcommitment_trunk_preload_bytes_totalare declared intrunk_pin_metrics.gobut never written anywhere in the tree, so both read0for the life of the process.Confirmed on a live Gnosis node with 5.9 days of uptime and 68,732 recorded preload extensions:
The neighbouring counters work; only these two are dead. The result is that there is no metric signal for how much work the adaptive pin controller does or how long it spends doing it. That gap was noticed while diagnosing #23066 — a livelock inside
ContractTrunkPreloadParallel.Run— where these counters would have been the natural place to see preload time climbing.Change
Record both at the two places a preload actually runs, covering the parallel and serial paths in each:
promoteLocked— the initial view for a newly promoted contract.runExtensionLocked— the per-block extension step, which is the dominant path in a running node.A promote whose
Runfails has its pins rolled back viaInvalidate, so it contributes its duration but no bytes. That is whyrecordPreloadtakes the byte count as a parameter instead of reading it back off the preloader.No behaviour change beyond the counters; no new metric names, cardinality, or hot-path work (both call sites already run once per contract per block under
c.mu).Testing
TDD, red → green. Both tests fail on
mainwith the counters flat at0:TestAdaptivePin_PromoteRecordsPreloadMetrics— both counters advance across a promote.TestAdaptivePin_ExtendRecordsPreloadMetrics— both counters advance across an extension, with the initial view budgeted so the queue survives promotion and there is real work left to measure.Each test guards against a vacuous pass by first asserting the preload actually pinned bytes / left a non-empty queue.
Full
execution/commitment/...suite passes.make lintclean for the touched files.Relationship to #23066
Split out of #23066 review discussion to keep that fix minimal. The two branches touch disjoint files (
adaptive_pin.go/trunk_pin_metrics.gohere,preload_parallel.gothere). Verified by trial-merging the two branches: no conflicts, merged result builds and the full package suite passes. They can land in either order.