feat(engine): add persistence completion wake channel #20626
+101
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on #20616 I noticed that there is kind of a fixed delay until a block(s) is finally persisted ~500ms. The idea in the PR is to add channel to notify the listener when the persistence is finished. This allows to wake up before the timeout is triggered, since it may that there is no new engine event that will trigger the wakeup. The timeout is still there as safety net. The latency is still higher than I expected, but not fixed and better as before.
Overall the next message is proceed when:
reth/crates/engine/tree/src/tree/mod.rs
Lines 1203 to 1218 in ad37490
I used https://github.com/cakevm/reth-stale-direct-db to test the latency:
Before (usually it is around 500ms, I picked some worst case).
latency_ms=501is the latency between newHead and the persisted event from #20616 is received.After:
Switched around 13:30 to this branch (before #20616). I do not have a good explanation for the outliners. But they seem not related to this PR and have been around before. Overall the access time to new state looks better.

PS:
to_tree_txuse now crossbeam to make use ofselect!.