Implement pre_load
/ post_load
for the views.
#2213
Open
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.
Motivation
The loading of the views leads to a flurry of independent
read_value_bytes
which strain the storage. This PR groups the access into a single query.Proposal
The following was done:
pre_load
andpost_load
are introduced.NUM_INIT_KEYS
static variable is introduced because so far the loading leads to a constant number of reads per view.fn load
was changed to use thepre_load
/post_load
.Next steps:
fn load
as a trait function. But we have now 3 kinds of such load functions so maybe the unification is not a good idea.try_load_entries_mut
ofreentrant_collection_view
so that it uses thepre_load
/post_load
.Test Plan
The CI of the view is already challenging enough and do not need to be expanded.
How much of an improvement has been computed:
Release Plan
This should be documented as it is an API change.
Links