-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
trie_prefetcher: alternate structure #666
base: master
Are you sure you want to change the base?
Conversation
defer func() { | ||
type closer interface { | ||
Close() | ||
} | ||
if closer, ok := p.db.(closer); ok { | ||
closer.Close() | ||
} | ||
}() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added compared to upstream
if trie, ok := sf.trie.(waiter); ok { | ||
trie.Wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added compared to upstream
@@ -59,7 +59,8 @@ func filledStateDB() *StateDB { | |||
|
|||
func TestCopyAndClose(t *testing.T) { | |||
db := filledStateDB() | |||
prefetcher := newTriePrefetcher(db.db, db.originalRoot, "", maxConcurrency) | |||
prefetchDb := newPrefetcherDatabase(db.db, maxConcurrency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to preserve existing UT behavior for now
3d6f372
to
f3612cd
Compare
sf.dups++ | ||
} else { | ||
if len(task) == common.AddressLength { | ||
sf.trie.GetAccount(common.BytesToAddress(task)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could do something more explicit here instead of wrapping GetAccount at the cost of more modifications, if desired.
Signed-off-by: Darioush Jalali <[email protected]>
Why this should be merged
The current trie_prefetcher is modified significantly compared to upstream, which makes it difficult to merge changes from upstream.
This PR aims to preserve the existing behavior but only with minor inline modifications to upstream code.
I would be open to other structures with the same idea.
How this works
Uses a wrapper for DB to track the central worker pool.
Adds a couple hooks for stopping the background processes.
How this was tested
CI