-
Notifications
You must be signed in to change notification settings - Fork 142
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
fix(store): caching account and validator in store #513
Merged
Conversation
This file contains 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
@b00f All things is okay for merging. |
Codecov Report
@@ Coverage Diff @@
## main #513 +/- ##
==========================================
+ Coverage 83.05% 83.15% +0.09%
==========================================
Files 154 154
Lines 7313 7306 -7
==========================================
+ Hits 6074 6075 +1
+ Misses 955 951 -4
+ Partials 284 280 -4 |
themantre
reviewed
Jun 16, 2023
themantre
reviewed
Jun 16, 2023
themantre
reviewed
Jun 16, 2023
themantre
reviewed
Jun 16, 2023
themantre
reviewed
Jun 16, 2023
Remove |
themantre
reviewed
Jun 16, 2023
themantre
reviewed
Jun 16, 2023
themantre
approved these changes
Jun 16, 2023
themantre
approved these changes
Jun 16, 2023
b00f
changed the title
fix: caching account and validator in store
fix(store): caching account and validator in store
Jun 17, 2023
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.
Description
The primary objective of this PR is to enhance the performance of the software and it also aims to reduce the syncing time. Executing each transaction requires fetching the corresponding account or validator information from LevelDB. Since database read/write operations are costly, they can significantly impact performance.
To mitigate this, we've implemented caching for accounts and validators based on their addresses. This approach allows us to write data into the DB, while reading account or validator information is performed from the cached data.
Since we are utilizing a map for caching, the complexity of fetching data is
O(1)
, which ensures optimal performance. However, if the number of accounts becomes large, for example more than 1 million, we may need to use an LRU cache.Another modification introduced in this PR is the implementation of the clone function for validators and accounts. Within both the sandbox and store packages, we assign objects by pointer and return a cloned object.