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

core/rawdb: add ability to retrieve freezer data iteratively #20308

Closed
wants to merge 1 commit into from

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Nov 18, 2019

This PR does not change any existing functionality in go-ethereum, but does add a new Api-method on freezertable, which might be useful in the future.
The RetrieveN method fetches the data from the underlying datastore in one disk-access, and returns the result in an iterator.

The idea is that instead of doing 8M disk accesses for e..g iterating the canon hashes, we can do a few orders of magnitude less disk accesses.
This can be useful in the following scenarios:

  • Initiating chain from ancients,
  • Delivering headers to peers,
  • Delivering block bodies/receipts to peers,

)
current := start
for nItems < max {
nextStart, nextEnd, nextFile, err := t.getBounds(current)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we really want to go nuts, we can optimize this too and do t.getBoundsN, to read n index entries in one go. But I'll leave that for later/someone else

@holiman
Copy link
Contributor Author

holiman commented Jan 28, 2020

Closing this, it's currently not used -- I experimented with it on the reinitialize-chain-from-ancients. It shaved off a bit of time, but since the big bottleneck is that we also need to write stuff to leveldb, it doesn't really motivate the added complexity.

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

Successfully merging this pull request may close these issues.

2 participants