-
Notifications
You must be signed in to change notification settings - Fork 397
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(x/params): add lru caching #3120
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
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.
What are the performance gains of this PR? K/V storages usually have cache mechanisms like the one implemented here, so maybe it is redundant?
@@ -7,6 +7,7 @@ import ( | |||
"github.com/gnolang/gno/tm2/pkg/amino" | |||
"github.com/gnolang/gno/tm2/pkg/sdk" | |||
"github.com/gnolang/gno/tm2/pkg/store" | |||
"github.com/golang/groupcache/lru" |
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.
Maybe this lib is more maintained than the one used: https://github.com/hashicorp/golang-lru
if bz == nil { | ||
return | ||
} |
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.
what is the meaning of that code? can we have nil values in our cache? why?
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 was considering the two situations, and I feel that since the goal is to avoid unnecessary lookups, caching the "not found" error prevents a misconfigured script from periodically querying the same nonexistent value for a real lookup.
It's just a feeling; I'm not sure if that's the best approach.
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.
we can use bloom filters for that specific case if we receive a lot of queries for data we don't have.
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
This PR is a bit old, and I know there's other developments on the params module. @moul, tell me if you want me to take a look or I can hold off the review for the moment. |
LRU caching uses a specified
CacheMaxSize
to limit the number of entries. Keys are immediately invalidated when a setter is called. The LRU is shared across all the getters.Fix #3023
Related with #2911