perf: cheaper metrics and logs while transaction lock is held - #2675
Conversation
PR Reviewer Guide 🔍(Review updated until commit 6e74658)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
Summary
Nice refactor overall — the new #[timed] attribute and per-FoundAt storage metrics significantly simplify call sites and make read-path observability richer.
I found one blocking correctness issue in transaction persistence flow introduced by the refactor.
Blocking finding
set_mined_block_number moved inside commit_changes and is now executed while latest_state_lock write guard is still held. Previously, the mined-number update happened after dropping that lock. Since reads of latest account/slot data are contractually synchronized with this lock, advancing mined block number before releasing it can expose a state where mined_number is visible as advanced while readers are still blocked from seeing corresponding latest state/cache updates, which can violate ordering assumptions in concurrent callers.
Please restore the prior ordering boundary (drop write guard before publishing mined-number advancement), or explicitly document/enforce that consumers never observe mined_number independently of this lock.
|
Persistent review updated to latest commit 6e74658 |
PR Code Suggestions ✨No code suggestions found for the PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e746580d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Benchmark: Git Info:
Leader Stats: Follower Stats: Plots: |
|
Forwarding benchmark: Git Info:
Follower Stats (transactions sent to follower): Plots: |
There was a problem hiding this comment.
Summary
Great refactor direction overall (macro-based timing + FoundAt-aware storage metrics), but I found one blocking correctness issue still present in this head.
Blocking
#[timed] on async trait impl methods that return impl Future is currently timing future construction, not awaited execution, so import_online_mined_block latency is effectively near-zero and no longer represents real import work time. This regresses metric correctness in all importer workers using that annotation.
|
Forwarding benchmark: Git Info:
Follower Stats (transactions sent to follower): Plots: |
|
Forwarding benchmark: Git Info:
Follower Stats (transactions sent to follower): Plots: |
|
Final benchmark: Git Info:
Leader Stats: Follower Stats: Plots: |
PR Type
Enhancement
Description
Replace manual timing calls with #[timed] attribute
Introduce ExecutionMetrics and StorageMetrics with FoundAt
Refactor StratusStorage to return (value, FoundAt)
Extract EntityRead trait and state lock into types
File Walkthrough
15 files
Refactor reads to return FoundAt and remove manual metricsApply #[timed] and use ExecutionMetrics contextImplement timed attribute macro for metricsProfile reads with Instant and record StorageMetricsDefine ExecutionMetrics and StorageMetrics structsAdd ToMetricLabelValue trait for parametersAdd record and record_async helpersIntroduce Semaphore and Permit typesExtract EntityRead trait into its own moduleAdd FoundAt enum for read-source trackingUse ExecutionMetrics instead of old metrics typeInstrument read_pending_execution with #[timed]Wrap buffer creation and send with #[timed]Add #[timed] to import online mined blockInstrument replication importer with #[timed]1 files
Update histogram definitions for evm storage metrics1 files
Move LatestStateLock into types module19 files