Avoid looking up previous version of nodes that are new#331
Merged
afterdusk merged 4 commits intofacebook:mainfrom Jan 3, 2023
Merged
Avoid looking up previous version of nodes that are new#331afterdusk merged 4 commits intofacebook:mainfrom
afterdusk merged 4 commits intofacebook:mainfrom
Conversation
Contributor
|
Can we get the statistics on an integration test suite to see whether we are using any |
slawlor
approved these changes
Jan 3, 2023
Contributor
slawlor
left a comment
There was a problem hiding this comment.
We'll follow up with automated tests once we have a storage mock imported
eozturk1
approved these changes
Jan 3, 2023
Contributor
eozturk1
left a comment
There was a problem hiding this comment.
Thanks for sharing the metrics, looks great!
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.
Overview
When writing tree nodes to storage, we look up previous versions of the node to create the
TreeNodeWithPreviousValuestruct. However, this is not necessary when we know a node is new and does not have a previous value. By keeping track of whether a node is new, we save on incurring an unnecessary round trip to the database.This PR performs the requisite change.
I would have liked to add a test for this change, however I cannot think of a straightforward way to assert that the database is not read beyond the initial preload. I believe this is something that can be addressed by bringing in a mocking library to mock out the
Databasetrait, or implementing an in-memory database which we can mock. Filed an issue regarding this: #332Manual Test
Added the following test to
append_only_zks.rs, which batch inserts 10 nodes on an empty tree and prints database access metrics:The test was ran with the following command:
$ cargo test test_get_count -- --nocaptureIf the change works, no gets are expected as the insert was performed on an empty tree with nothing to preload.
Before
On the
mainbranch, with 7878bcb cherry-picked:19 gets are performed.
After
On this PR's branch:
Indeed the number of gets are now 0.