Skip to content

feat(engine): support dual-frontier partial trie persistence#23592

Closed
mediocregopher wants to merge 78 commits into
mainfrom
mediocregopher/partial-persistence
Closed

feat(engine): support dual-frontier partial trie persistence#23592
mediocregopher wants to merge 78 commits into
mainfrom
mediocregopher/partial-persistence

Conversation

@mediocregopher
Copy link
Copy Markdown
Member

@mediocregopher mediocregopher commented Apr 16, 2026

Tracks partial trie durability in FinishCheckpoint.partial_state_trie and teaches engine persistence to plan around separate non-trie and trie frontiers. Updates provider save, read, and unwind paths to anchor overlays to the durable trie frontier, only mask trie writes for deferred blocks whose non-trie data is durably written, and preserve the partial trie frontier across truncation. This keeps historical state reconstruction, overlay caching, and engine unwind behavior correct when trie persistence lags the fully durable Finish checkpoint.

Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d9639-935f-73a4-ba50-7682a7b9aca0
Co-authored-by: Amp <amp@ampcode.com>
@github-project-automation github-project-automation Bot moved this to Backlog in Reth Tracker Apr 16, 2026
@mediocregopher mediocregopher self-assigned this Apr 16, 2026
@mediocregopher mediocregopher added A-trie Related to Merkle Patricia Trie implementation C-perf A change motivated by improving speed, memory usage or disk footprint labels Apr 16, 2026
@mediocregopher mediocregopher marked this pull request as draft April 16, 2026 12:49
mediocregopher and others added 21 commits April 16, 2026 12:55
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d9639-935f-73a4-ba50-7682a7b9aca0
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d968b-970d-735e-844c-b83ff245ce05
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d968b-970d-735e-844c-b83ff245ce05
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d9728-846b-7418-8a69-ddbba65ce656
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d9728-846b-7418-8a69-ddbba65ce656
Co-authored-by: Amp <amp@ampcode.com>
Raise the default persistence threshold to 10 and derive the default backpressure threshold from the persistence and in-memory thresholds. Enable alloy getrandom for reth-engine-primitives tests so the existing B256::random() test coverage keeps compiling.

Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d9a2b-716e-774d-8db7-b0308fa96a23
Co-authored-by: Amp <amp@ampcode.com>
Make masked save_blocks persistence track partial trie progress in the Finish checkpoint and switch the trie-masking API to a masked-suffix start index so the final block is always covered by the mask when partial trie persistence is used.

Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d9a2b-716e-774d-8db7-b0308fa96a23
Co-authored-by: Amp <amp@ampcode.com>
Return finish-stage partial trie progress from the persistence thread and keep blocks above that trie boundary resident in memory after persistence completes.

This preserves the old prune-through-tip behavior when the partial trie matches the persisted tip or is absent.

Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019d9ab4-1eab-713f-9d5d-71903b7bc724
Co-authored-by: Amp <amp@ampcode.com>
Co-Authored-By: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dab40-7d65-709b-90d6-98965c5c6a65
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dab40-7d65-709b-90d6-98965c5c6a65
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dab6f-7cee-755e-9f9c-309ae0b8517c
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dab6f-7cee-755e-9f9c-309ae0b8517c
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019daba4-3598-758d-8771-cb5db784db81
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019daba4-3598-758d-8771-cb5db784db81
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019daba4-3598-758d-8771-cb5db784db81
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dafa5-05ee-739e-a0b6-037cc30e4a0e
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019daba4-3598-758d-8771-cb5db784db81
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dafbb-3571-73ef-ae67-43c242e2bf23
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dafbb-3571-73ef-ae67-43c242e2bf23
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019dafbb-3571-73ef-ae67-43c242e2bf23
Co-authored-by: Amp <amp@ampcode.com>
mediocregopher and others added 22 commits May 4, 2026 10:56
Keep restart trace capture on the failed unwind path, but run the post-drop Merkle rebuild at info level without a separate trace artifact.
This keeps the repro focused on restart-trace.log while preserving the existing post-drop verification step.

Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df291-fde0-73c9-ad81-f516190fc3ad
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df3d9-cf72-713e-8a8e-9d3ab36f83f0
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df406-d380-704b-8376-32b9bbcbce7c
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df406-d380-704b-8376-32b9bbcbce7c
Co-authored-by: Amp <amp@ampcode.com>
Co-Authored-By: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df4c4-1820-728c-a2c2-bae7d3a17ae3
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df7cd-9370-777b-9be4-b151c795829b
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df7cd-9370-777b-9be4-b151c795829b
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df7cd-9370-777b-9be4-b151c795829b
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df84d-0048-705b-97b4-e199ea9ddf6f
Co-authored-by: Amp <amp@ampcode.com>
…l-persistence

Co-Authored-By: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Co-Authored-By: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019df965-c32c-7188-831c-c5d6ea37e036
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e02e7-d893-749b-9ba7-fde95abec62f
Co-authored-by: Amp <amp@ampcode.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e02e7-d893-749b-9ba7-fde95abec62f
Co-authored-by: Amp <amp@ampcode.com>
@mediocregopher
Copy link
Copy Markdown
Member Author

derek bench big-blocks blocks=500 slack=on-win baseline-args='--engine.persistence-threshold=13' feature-args='--engine.persistence-threshold=13 --engine.deferred-trie-blocks=10'

@decofe
Copy link
Copy Markdown
Member

decofe commented May 7, 2026

cc @mediocregopher

✅ Benchmark complete! View job

Benchmark Results

⚠️ Feature is 1 commit behind main. Consider rebasing for accurate results.

Metric main mediocregopher/partial-persistence Change
Mean 657.29ms 703.13ms +6.97% ❌ (±0.37%)
StdDev 116.45ms 123.70ms
P50 627.66ms 673.48ms +7.30% ❌ (±0.90%)
P90 801.54ms 858.31ms +7.08% ❌ (±1.55%)
P99 1080.32ms 1166.67ms +7.99% ❌ (±3.40%)
Mgas/s 1588.53 1483.92 -6.59% ❌ (±0.36%)
Wall Clock 665.24s 711.30s +6.93% ❌ (±0.37%)
Persist Wait 295.08ms 729.43ms +147.20% ❌ (±33.52%)

500 big blocks, driver: reth-bench (fallback: big-blocks), 20 warmup

Wait Time Breakdown

Persistence Wait

Metric main mediocregopher/partial-persistence
Mean 295.08ms 729.43ms
P50 0.05ms 0.05ms
P95 3908.63ms 9927.24ms

Trie Cache Update Wait

Metric main mediocregopher/partial-persistence
Mean 0.09ms 0.60ms
P50 0.00ms 0.00ms
P95 0.00ms 0.00ms

Execution Cache Update Wait

Metric main mediocregopher/partial-persistence
Mean 0.00ms 0.00ms
P50 0.00ms 0.00ms
P95 0.00ms 0.00ms

Grafana Dashboard

Charts

Latency, Throughput & Diff

Latency, Throughput & Diff

Wait Time Breakdown

Wait Time Breakdown

Gas vs Latency

Gas vs Latency

Grafana Dashboard

View real-time metrics

mediocregopher and others added 3 commits May 8, 2026 18:18
Co-Authored-By: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Co-Authored-By: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Co-authored-by: Brian Picciano <933154+mediocregopher@users.noreply.github.com>
Amp-Thread-ID: https://ampcode.com/threads/T-019e108f-c77e-712f-a377-a0148ea5feb9
Co-authored-by: Amp <amp@ampcode.com>
@mediocregopher
Copy link
Copy Markdown
Member Author

Closed in favor of the cleaned replacement PR: #24100

@github-project-automation github-project-automation Bot moved this from Backlog to Done in Reth Tracker May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-trie Related to Merkle Patricia Trie implementation C-perf A change motivated by improving speed, memory usage or disk footprint

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants