Perf/clarity contract cache#2
Closed
cylewitruk-stacks wants to merge 7 commits into
Closed
Conversation
This file contains hidden or 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
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
Builds on stacks-network#7049 (
ResidentBytesimpl) for calculating resident memory size.Adds a size-weighted read-through
TinyUFOcache (written by Cloudflare; usesS3-FIFOeviction +TinyLFUadmission) for parsed ClarityContractinstances:CACHE_WEIGHT_UNITof256, which theresident_bytes()size of aCachedContractis divided by (sinceTinyUFO's weight system usesu16), allowing for a maximum cacheable entry size of roughly16MiBeach.DEFAULT_CONTRACT_CACHE_SIZEis set to64MiB(64 * 1024 * 1024), which gives a cache-wide weight limit of262,144units.TinyUFOenforces this budget on every insertion, evicting entries by access frequency to stay within the limit.Applicable issues
Additional info (benefits, drawbacks, caveats)
NOTE: The cache is implemented as a node-level cache and as such is purely a node optimization; a next iteration which incorporates tx-level caching policy for targeting tenure budgets could implement its own tx-scoped cache on top of the node-level cache with stricter/deterministic policy.
Some benchmark results:
Checklist
changelog.d/README.md)