Skip to content

perf: defer ExecutedBlock drop to background thread#22080

Draft
yongkangc wants to merge 1 commit intomainfrom
yk/deferred-block-drop
Draft

perf: defer ExecutedBlock drop to background thread#22080
yongkangc wants to merge 1 commit intomainfrom
yk/deferred-block-drop

Conversation

@yongkangc
Copy link
Member

@yongkangc yongkangc commented Feb 11, 2026

Summary
When blocks are evicted from the in-memory TreeState after persistence, ExecutedBlock drops happen on the engine thread. The TrieUpdatesSorted drop cascade (Arc<Vec<B256>> inside BranchNodeCompact) triggers hundreds of small deallocations through cold cache lines, consuming ~2% of engine thread CPU. This PR defers evicted block drops to a rayon background task.

Changes

  • remove_canonical_until() and prune_finalized_sidechains() return evicted blocks instead of dropping them
  • remove_until() collects evicted blocks and defers drop via rayon::spawn

When blocks are evicted from the in-memory tree (after persistence or
finalization), the engine thread must drop ExecutedBlock values which
contain Arc<TrieUpdatesSorted>. Dropping these involves recursive
deallocation of BranchNodeCompact chains with inner Arc<Vec<B256>> hash
vectors. Profile data shows this costs ~2% of engine thread time.

Move the drop to a rayon::spawn background task so the engine thread
can immediately continue processing.

Amp-Thread-ID: https://ampcode.com/threads/T-019c4dab-6735-7327-90fb-3a9067d10d9e
@yongkangc yongkangc added C-perf A change motivated by improving speed, memory usage or disk footprint A-engine Related to the engine implementation labels Feb 11, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Feb 11, 2026
@github-actions
Copy link
Contributor

⚠️ Changelog not found.

A changelog entry is required before merging. We've generated a suggested changelog based on your changes:

Preview
---
reth-engine-tree: patch
---

Deferred `ExecutedBlock` drop to background thread after eviction to reduce engine thread blocking time during block removal operations.

Add changelog to commit this to your branch.

@yongkangc yongkangc self-assigned this Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-engine Related to the engine implementation C-perf A change motivated by improving speed, memory usage or disk footprint

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant