-
Notifications
You must be signed in to change notification settings - Fork 140
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
@@ -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
Signed-off-by: Darioush Jalali <[email protected]>
…abs/coreth into trie-prefetcher-alt
|
||
// triePrefetcher is an active prefetcher, which receives accounts or storage | ||
// items and does trie-loading of them. The goal is to get as much useful content | ||
// into the caches as possible. | ||
// | ||
// Note, the prefetcher's API is not thread safe. | ||
type triePrefetcher struct { | ||
db Database // Database to fetch trie nodes through | ||
db PrefetcherDB // Database to fetch trie nodes through |
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.
changed compared to upstream
var pdb PrefetcherDB | ||
pdb = withPrefetcherDefaults{db} | ||
if db, ok := db.(withPrefetcherDB); ok { | ||
pdb = db.PrefetcherDB() | ||
} |
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.
changed compared to upstream
storageFetchers int64 | ||
largestLoad int64 | ||
) | ||
defer p.db.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
p *triePrefetcher | ||
|
||
db Database // Database to load trie nodes through | ||
db PrefetcherDB // Database to load trie nodes through |
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.
modified compared to upstream
return 0 | ||
} | ||
return sf.to.copies | ||
sf.db.WaitTrie(sf.trie) |
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
sf.db.PrefetchAccount(sf.trie, common.BytesToAddress(task)) | ||
} else { | ||
sf.db.PrefetchStorage(sf.trie, sf.addr, 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.
modified. compared to upstream (made this more explicit to avoid overriding GetAccount and GetStorage)
Adding do not merge label prior to verifying performance |
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