-
Notifications
You must be signed in to change notification settings - Fork 618
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
vm: AnyCache
#10825
vm: AnyCache
#10825
Conversation
This cache is more general than the previous cache and also better abstracted in that it allows storing anything into it, and permits configuration of it from outside the contract runtime. Also no global statics (other than for the empty cache sentinel.)
Simplifies the code quite a bit.
The blast radius... Thank dog I decided against upgrading lru for the entire workspace or I'd be sitting doing just that till deep winter.
Pending: unit tests, benchmark results, configuration of the cache size. |
Alas this didn't pan out quite yet -- instantiation still requires an `Arc<Artifact>` and removing that requirement is not the right time right now
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10825 +/- ##
==========================================
+ Coverage 71.57% 71.60% +0.02%
==========================================
Files 760 760
Lines 153133 153263 +130
Branches 153133 153263 +130
==========================================
+ Hits 109607 109740 +133
+ Misses 38539 38535 -4
- Partials 4987 4988 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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'm leaving some initial questions and comments. Since it is the first time I'm looking at the compiled contract cache, I'll need to do another review.
Should cache eviction be tested or can this functionality be considered handled by lru
and hence not tested here?
Yeah I think this is entirely a concern for the underlying crate. We might also just use a different algorithm soon, so eviction algorithm might change too... |
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.
LGTM.
`AnyCache` is a part of the now-expanded concept of the `ContractRuntimeCache`. It allows runtimes to put anything they would like into it, so long as this cache is keyed by `CryptoKey`. Initially I was in a lot of pain as intermediate drafts have required me to add a `unsafe impl Sync for UniversalArtifact` which I'm not sure I could possibly prove. However in the end I ended up being able to avoid it entirely by giving out `AnyCache` by reference only. Lovely! -- EDIT: crappa, looks like I did something wrong testing this locally T_T Sync appears to remain a requirement. Note that only NearVM uses this cache currently. I don't see a good reason to port this code back to the old runtimes. Supersedes near#10787 Co-authored-by: Longarithm <the.aleksandr.logunov@gmail.com>
`AnyCache` is a part of the now-expanded concept of the `ContractRuntimeCache`. It allows runtimes to put anything they would like into it, so long as this cache is keyed by `CryptoKey`. Initially I was in a lot of pain as intermediate drafts have required me to add a `unsafe impl Sync for UniversalArtifact` which I'm not sure I could possibly prove. However in the end I ended up being able to avoid it entirely by giving out `AnyCache` by reference only. Lovely! -- EDIT: crappa, looks like I did something wrong testing this locally T_T Sync appears to remain a requirement. Note that only NearVM uses this cache currently. I don't see a good reason to port this code back to the old runtimes. Supersedes #10787 Co-authored-by: Longarithm <the.aleksandr.logunov@gmail.com>
AnyCache
is a part of the now-expanded concept of theContractRuntimeCache
. It allows runtimes to put anything they would like into it, so long as this cache is keyed byCryptoKey
.Initially I was in a lot of pain as intermediate drafts have required me to add a
unsafe impl Sync for UniversalArtifact
which I'm not sure I could possibly prove. However in the end I ended up being able to avoid it entirely by giving outAnyCache
by reference only. Lovely! -- EDIT: crappa, looks like I did something wrong testing this locally T_T Sync appears to remain a requirement.Note that only NearVM uses this cache currently. I don't see a good reason to port this code back to the old runtimes.
Supersedes #10787
Co-authored-by: Longarithm the.aleksandr.logunov@gmail.com