-
Notifications
You must be signed in to change notification settings - Fork 129
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(trie): Implement LRU cache for in memory trie #3624
Conversation
…nto diego/statetrie/cache
…nto diego/statetrie/cache
…nto diego/statetrie/cache
lib/utils/lru-cache/lru_cache.go
Outdated
c.Lock() | ||
defer c.Unlock() | ||
|
||
return len(c.cache) |
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.
lruList has Len() attribute, it is 100% O(1) complexity while I am not sure about bult-in function
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.
Yes, it is O(1), go keeps track of the items amount internally
@@ -30,11 +29,12 @@ var ( | |||
}) | |||
) | |||
|
|||
const MaxInMemoryTries = 100 |
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.
How this was defined? Should we maybe add some description for this?
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.
This PR is still WIP, I want to use the same number used in substrate but I have to do a little research to find it. We don't use to review draft PRs because the code can change. Anyways, thanks for the comment.
…nto diego/statetrie/cache
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## development #3624 +/- ##
===============================================
+ Coverage 50.16% 50.46% +0.29%
===============================================
Files 229 229
Lines 28585 28608 +23
===============================================
+ Hits 14340 14437 +97
+ Misses 12723 12648 -75
- Partials 1522 1523 +1 |
Closing it. We are implementing the same in #3658 |
Changes
We added an implementation for a LRU cache to be used in our in memories tries and prevent having the entire trie list in memory with the goal of reducing the memory usage
Tests
make test
Issues
#3623
Primary Reviewer
@timwu20