refactor(trie): simplify LazyTrieData with SortedTrieData container#21153
Closed
refactor(trie): simplify LazyTrieData with SortedTrieData container#21153
Conversation
ea3499a to
5db33d8
Compare
This refactor simplifies the lazy trie data abstraction introduced in the previous PR: - Create SortedTrieData container bundling HashedPostStateSorted and TrieUpdatesSorted together - Simplify LazyTrieData to use single Arc<OnceLock<SortedTrieData>> instead of two separate OnceLocks - Remove TrieDataCompute trait in favor of simple Arc<dyn Fn()> - Remove Default impl for LazyTrieData (not needed) - Update DeferredTrieData::to_lazy() to use closure-based deferred computation The previous implementation was overly complex with: - Two separate OnceLock fields that could be initialized independently - A trait (TrieDataCompute) that was only implemented by one type - Unnecessary Default implementation This simplification makes the code easier to understand while maintaining the same lazy evaluation semantics. The computation is still deferred until first access, and clones share the cached state.
5db33d8 to
783ce91
Compare
Collaborator
Author
|
Closing to redo as part of a broader revert of #21137 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Simplifies the
LazyTrieDataabstraction introduced in #21139.Changes
SortedTrieDatacontainer bundlingHashedPostStateSorted+TrieUpdatesSortedLazyTrieDatato use singleArc<OnceLock<SortedTrieData>>instead of two separateOnceLocksTrieDataComputetrait - use simpleArc<dyn Fn() -> SortedTrieData>insteadDefaultimpl forLazyTrieDataThe previous implementation had two separate
OnceLockfields and a trait that was only implemented by one type. This consolidates everything into a simpler design while maintaining the same lazy evaluation semantics.