You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR wires the neutral trace cache from PR #4065 across RPC v8, v9, and v10
Refactors version-specific adaptation into helpers
Adds integration tests for cache sharing and version-specific behavior.
Benchmark
Cross-Version Trace Cache
Answers the question: Does sharing one block-trace execution across concurrent v8/v9/v10 block and transaction requests improve performance, and what overhead per-request response adaptation introduces on cache hits?
Setup
Request Set:
- 50% traceBlockTransactions, 50% traceTransaction
- Equal distribution across v8, v9, and v10
Working set:
- 32 measured blocks, plus one separate startup-warmup block
- Each sampled row is run 3 times (mean taken)
Iterations per sample:
- Cold: 32 burst iterations, each sending N concurrent RPC requests
- Warm: 393,216 iterations, each sending one RPC request
Cold Trace Workload Matrix
Each "burst" targets one initially uncached block B and one fixed transaction T inside B.
Request
RPC v8
RPC v9
RPC v10
Block trace
traceBlockTransactions(B)
traceBlockTransactions(B)
traceBlockTransactions(B)
Transaction trace
traceTransaction(T)
traceTransaction(T)
traceTransaction(T)
The concurrency controls the copies of each request.
Concurrency
Copies of each table cell
Requests per burst
6
1
6
24
4
24
96
16
96
192
32
192
Example:
Send the burst for block B1 and transaction T1; wait for all responses.
Send the burst for block B2 and transaction T2; wait for all responses.
Continue through 32 distinct blocks.
Warm Cache Workload Matrix
Concurrency
Virtual users
Total RPC requests
Average requests per VU
6
6
393,216
65,536
24
24
393,216
16,384
96
96
393,216
4,096
192
192
393,216
2,048
Cross-Version Trace Cache:
Cache
Concurrency
Throughput
p50 latency
p95 latency
CPU time
Peak RSS
Cold
6
+12.5%
-7.4%
-5.5%
-81.9%
-23.8%
Cold
24
+244.9%
-56.0%
-52.4%
-95.3%
-32.8%
Cold
96
+1106.3%
-85.2%
-82.3%
-98.7%
-32.3%
Cold
192
+2016.9%
-91.9%
-90.8%
-99.3%
-30.8%
Warm
6
-0.8%
+1.6%
+2.4%
+1.7%
-18.3%
Warm
24
-0.9%
+0.5%
+2.8%
+1.2%
-23.8%
Warm
96
-0.9%
+2.4%
+1.4%
+1.9%
-24.3%
Warm
192
~0.0%
+2.0%
+2.7%
+0.2%
-23.8%
Concurrent Cache-Hit Benchmark
Answers the question: “How much does serializing cache access through a single mutex cost as concurrency increases, and is that an acceptable tradeoff for a simpler design?
p50 samples remained below 0.2 µs at every tested concurrency.
Overhead from minimal design choice is negligible.
Setup
1 second measuring throughput, 1 separate second sampling latency
3x per sample (mean taken)
Concurrent Cache-Hit Benchmark:
Keys
Workers
Throughput (M hits/s)
p95 (µs)
p99 (µs)
1
1
45.94 → 58.44
0.033 → 0.030
0.034 → 0.031
1
6
107.70 → 19.09
0.043 → 0.390
1.081 → 3.576
1
24
58.87 → 14.89
0.921 → 1.734
9.153 → 47.968
1
192
57.15 → 10.96
1.103 → 7.836
157.440 → 519.347
32
1
35.73 → 45.81
0.039 → 0.033
0.042 → 0.035
32
6
96.90 → 11.66
0.074 → 2.348
1.418 → 19.604
32
24
47.51 → 13.09
1.440 → 5.234
17.268 → 64.260
32
192
35.22 → 6.76
3.986 → 183.766
215.974 → 679.776
PR Type
Enhancement, Tests
Description
Wire a shared tracecache across RPC v8, v9, and v10 handlers to reuse neutral block-trace executions.
Refactor trace adaptation logic into version-specific helpers (adaptCachedTrace, adaptCachedTraces).
Replace lru.Cache with tracecache.Cache for coordinating block trace queries and caching results.
Add comprehensive integration tests covering shared cache concurrency, version shapes, and failure handling.
❌ Patch coverage is 91.53439% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.43%. Comparing base (d7b9154) to head (52db996).
traceFinalisedBlock and traceBlockTransactions (v8) call defer lease.Abort() right after acquiring a lease, and then explicitly call lease.Publish(...) on success paths before returning. Since the deferred Abort() still executes after Publish() on every return path, correctness depends entirely on Lease.Abort() being a safe no-op once Publish() has already been called. If that invariant does not hold (e.g. it re-releases waiters or double-frees internal state), concurrent v8/v9/v10 callers waiting on the same block hash could see corrupted or duplicate cache entries. This is not verifiable from the diff alone since tracecache.Lease internals aren't shown, but it is the central correctness assumption of the whole shared-cache design.
adaptCachedTrace and adaptCachedTraces are duplicated nearly verbatim across rpc/v8/adapters.go, rpc/v9/adapters.go, and rpc/v10/adapt_trace.go. Any future fix to gas/resource mapping logic must be applied in three places, increasing the risk of the versions drifting out of sync.
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
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.
User description
This PR wires the neutral trace cache from PR #4065 across RPC v8, v9, and v10
Benchmark
Cross-Version Trace Cache
Answers the question: Does sharing one block-trace execution across concurrent v8/v9/v10 block and transaction requests improve performance, and what overhead per-request response adaptation introduces on cache hits?
Setup
Request Set:
- 50% traceBlockTransactions, 50% traceTransaction
- Equal distribution across v8, v9, and v10
Working set:
- 32 measured blocks, plus one separate startup-warmup block
- Each sampled row is run 3 times (mean taken)
Iterations per sample:
- Cold: 32 burst iterations, each sending N concurrent RPC requests
- Warm: 393,216 iterations, each sending one RPC request
Cold Trace Workload Matrix
Each "burst" targets one initially uncached block B and one fixed transaction T inside B.
The concurrency controls the copies of each request.
Example:
Warm Cache Workload Matrix
Cross-Version Trace Cache:
Concurrent Cache-Hit Benchmark
Answers the question: “How much does serializing cache access through a single mutex cost as concurrency increases, and is that an acceptable tradeoff for a simpler design?
Setup
Concurrent Cache-Hit Benchmark:
PR Type
Enhancement, Tests
Description
Wire a shared
tracecacheacross RPC v8, v9, and v10 handlers to reuse neutral block-trace executions.Refactor trace adaptation logic into version-specific helpers (
adaptCachedTrace,adaptCachedTraces).Replace
lru.Cachewithtracecache.Cachefor coordinating block trace queries and caching results.Add comprehensive integration tests covering shared cache concurrency, version shapes, and failure handling.
File Walkthrough
10 files
Inject shared trace cache across RPC handlersAdd helpers to adapt cached traces to v10 typesUpdate v10 handler to use `tracecache.Cache`Refactor v10 trace fetching to use `tracecache` mechanismsAdd helpers to adapt cached traces to v8 typesUpdate v8 handler to use `tracecache.Cache`Refactor v8 trace fetching to use `tracecache` mechanismsAdd helpers to adapt cached traces to v9 typesUpdate v9 handler to use `tracecache.Cache`Refactor v9 trace fetching to use `tracecache` mechanisms5 files
Add integration tests for shared trace cacheAdd tests for trace adaptation allocationsUpdate v10 tests to reflect new trace response structuresUpdate v8 tests to reflect new trace response structuresUpdate v9 tests to reflect new trace response structures