Skip to content

perf(debug-trace-server): build the witness execution form once per block - #185

Open
flyq wants to merge 1 commit into
liquan/chore/upgrade-reth-2.3from
liquan/perf/share-light-witness-executor
Open

perf(debug-trace-server): build the witness execution form once per block#185
flyq wants to merge 1 commit into
liquan/chore/upgrade-reth-2.3from
liquan/perf/share-light-witness-executor

Conversation

@flyq

@flyq flyq commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

Every trace request deep-cloned the block's LightWitness out of the shared Arc<BlockData> (data.witness.clone() — the multi-hundred-KB-to-MB kvs/levels maps) and then rebuilt the LightWitnessExecutor direct-lookup table from scratch, two O(witness) passes paid on every debug_traceTransaction (transaction responses are never response-cached) and on every block-level response-cache miss or bypass (JS, mux, struct-logger-with-flags). Surfaced by the review pass on #184 as the largest remaining hot-path allocation; pre-existing, so fixed here separately.

Change

BlockData.witness now stores the LightWitnessExecutor — witness plus lookup table — built once where the BlockData is assembled (DB load, remote fetch, test fixtures) and shared by every request served from that entry, including repeated traces of a hot block. The trace entry points (trace_block, trace_transaction, parity_trace_block, parity_trace_transaction) and TracingEnv borrow it (&LightWitnessExecutor); no per-request clone or table rebuild remains. LightWitnessExecutor gains light_witness() (for extract_code_hashes and witness-size accounting) and lookup_table_memory_bytes(), which the block-data cache weigher now charges alongside the witness payload so the cache budget reflects the stored table.

Testing

cargo test --workspace: 374 passed / 0 failed; clippy / fmt / cargo-sort clean.

Notes

Based on #184 (liquan/chore/upgrade-reth-2.3) — merge after it lands.

…lock

Every trace request deep-cloned the block's LightWitness (multi-hundred-KB
kvs/levels maps) out of the shared Arc<BlockData> and then rebuilt the
LightWitnessExecutor direct-lookup table from scratch — paid per
debug_traceTransaction (never response-cached) and per block-level cache
miss/bypass. BlockData now stores the LightWitnessExecutor, built once where
the BlockData is assembled (DB load, remote fetch, fixtures), and the trace
entry points borrow it; the block-data cache weigher charges the lookup
table alongside the witness payload.
@mega-maxwell

mega-maxwell Bot commented Aug 11, 2026

Copy link
Copy Markdown

Claude review status

Living comment — rewritten in place. The review workflow keeps this single comment up to date instead of posting a new one each round, so it always describes the latest reviewed commit and the earlier text is intentionally gone. No reply is needed here; reply to a finding in its own review thread, and answer an open question in a reply on this PR. The next review round reconciles your answer.

🛠️ Review did not finish

Attempted head 889c39f3 · updated 2026-08-11T01:22:31+00:00

This round did not publish: MODEL_ACTION_FAILED in phase review_retry. Anything listed below is from the last round that did. Re-run the workflow or push a new commit to try again.

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.9%. Comparing base (99485a5) to head (889c39f).

Files with missing lines Patch % Lines
crates/stateless-core/src/light_witness.rs 0.0% 7 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants