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.
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
feat: caching LookupSet implementation #654
feat: caching LookupSet implementation #654
Changes from all commits
9127ca7
cd8ede0
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Noting that one unintentional property that it will only cache the result if the map does not contain the key. The reason the map can't cache the fact that the key does exist, is because it does not actually read the value from storage.
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.
I will note that for things like this, it will incur a larger storage cost. If you look at https://github.com/near/nearcore/blob/d0087f6c5006c1bf581e2eb30ab430e89cb1bc74/nearcore/res/mainnet_genesis.json#L157 you can see
storage_read_base
(and per-key byte) is slightly larger thanstorage_has_key_base
. When doing this remove, it is doing a read of the bytes rather than just checking if it exists.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.
Thanks for the link, I will use it as a reference in the future
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.
Hmm, maybe I am misunderstanding something here, but I am confused what do
storage_read_base
andstorage_has_key_base
have to do withLookupMap::insert
. From what I see it just usesenv::storage_write
(that happens inflush()
) and nothing else. I don't see a more efficient way of writing a key to the trie other than writing the key itself and 0 bytes as the value (from what I understand writing charges a fixed base cost + per byte rate for both key and value data).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.
Same comment as before