perf(engine): handle EmptyProof inline during prefetch batching (#20848)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matthias Seitz
2026-01-08 20:12:14 +01:00
committed by GitHub
parent a06644944f
commit a5b10f11ce

View File

@@ -866,6 +866,8 @@ impl MultiProofTask {
ctx.accumulated_prefetch_targets.push(targets);
// Batch consecutive prefetch messages up to limits.
// EmptyProof messages are handled inline since they're very fast (~100ns)
// and shouldn't interrupt batching.
while accumulated_count < PREFETCH_MAX_BATCH_TARGETS &&
ctx.accumulated_prefetch_targets.len() < PREFETCH_MAX_BATCH_MESSAGES
{
@@ -880,6 +882,16 @@ impl MultiProofTask {
accumulated_count += next_count;
ctx.accumulated_prefetch_targets.push(next_targets);
}
Ok(MultiProofMessage::EmptyProof { sequence_number, state }) => {
// Handle inline - very fast, don't break batching
batch_metrics.proofs_processed += 1;
if let Some(combined_update) = self.on_proof(
sequence_number,
SparseTrieUpdate { state, multiproof: Default::default() },
) {
let _ = self.to_sparse_trie.send(combined_update);
}
}
Ok(other_msg) => {
ctx.pending_msg = Some(other_msg);
break;