Skip to content
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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

darioush
Copy link
Collaborator

@darioush darioush commented Oct 1, 2024

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

Comment on lines +87 to +94
defer func() {
type closer interface {
Close()
}
if closer, ok := p.db.(closer); ok {
closer.Close()
}
}()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added compared to upstream

Comment on lines +313 to +314
if trie, ok := sf.trie.(waiter); ok {
trie.Wait()
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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

sf.dups++
} else {
if len(task) == common.AddressLength {
sf.trie.GetAccount(common.BytesToAddress(task))
Copy link
Collaborator Author

@darioush darioush Oct 1, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant