Compare commits

...

1 Commits

Author SHA1 Message Date
Ubuntu
3c46b96bc3 perf(engine): skip dispatch pipeline when all proof targets already fetched
Add early return in on_hashed_state_update when not_fetched_state_update
is empty, avoiding unnecessary MultiAddedRemovedKeys clone, Arc
allocation, dispatch_with_chunking call, and proof target construction
for state updates where all accounts and storage slots were already
prefetched.

For small blocks (<50 txs) where prewarming runs ahead of execution,
many state updates will have all targets already fetched. Each
already-fetched update saves ~2-5µs by skipping:
- AddedRemovedKeys HashSet clone (~200-500ns)
- Arc allocation + later drop (~100-200ns)
- dispatch_with_chunking → get_proof_targets → dispatch → channel
  round trip (~500ns-2µs)
- ProofSequencer bookkeeping (~100ns)
- MultiProofTargets::default() + extend (~50-100ns)

Estimated savings for 30-tx block with ~20 prefetched updates: ~40-100µs

Amp-Thread-ID: https://ampcode.com/threads/T-019c5151-b4af-7475-a7d9-8cfa8f1d22aa
2026-02-12 10:16:22 +00:00

View File

@@ -889,6 +889,12 @@ impl MultiProofTask {
state_updates += 1;
}
// Fast path: if all targets were already fetched, skip the expensive
// MultiAddedRemovedKeys clone, dispatch_with_chunking, and proof target construction.
if not_fetched_state_update.is_empty() {
return state_updates;
}
// Clone+Arc MultiAddedRemovedKeys for sharing with the dispatched multiproof tasks
let multi_added_removed_keys = Arc::new(MultiAddedRemovedKeys {
account: self.multi_added_removed_keys.account.clone(),