-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Go API: Allow providing custom base cache #7329
Conversation
270c91d
to
4250404
Compare
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 reminds me, have you ever tested the new AST-Values-in-inmem-storage feature that shipped some time ago?
The same way it's possible to provide a VirtualCache, it should be possible to bring your own BaseCache. In clients like Regal (when invoked via `regal lint`), the base data is only ever loaded once and doesn't change later. Yet currently, each evaluation (of which there are hundreds) will have a new cache instantiated, leading to unnecessary cache misses. Since our inmem-store is AST-based, we could also try to have the base cache tap directly into the store for a 100% hit ratio, avoiding the more costly storage queries. But that's still untested this point 🤓 (The tiny changes in resolver.go are unrelated to this feature but fix a perf issue I noticed last night as I was testing that functionality. Too small fix to warrant a PR of its own.) Signed-off-by: Anders Eknert <[email protected]>
4250404
to
a7956af
Compare
Yes! It's enabled in Regal and helps quite a bit! That's what I was alluding to here:
Meaning even with that enabled, going to the cache is much cheaper than going via the storage API, where a single Read request costs 1 + x allocations just to convert a ref to path and back (where x is the length of the ref). That used to be 1 + 2x but was made a little cheaper recently by pooling. And that's just for the path — there are also costs attached to boxing values to (EDIT: For the The better solution would be a V2 storage API, and I think @johanfylling wished for that too after he worked on the AST backed inmem store. But that's for another day :) |
The same way it's possible to provide a VirtualCache, it should be possible to bring your own BaseCache. In clients like Regal (when invoked via
regal lint
), the base data is only ever loaded once and doesn't change later. Yet currently, each evaluation (of which there are hundreds) will have a new cache instantiated, leading to unnecessary cache misses.Since our inmem-store is AST-based, we could also try to have the base cache tap directly into the store for a 100% hit ratio, avoiding the more costly storage queries. But that's still untested this point 🤓
(The tiny changes in resolver.go are unrelated to this feature but fix a perf issue I noticed last night as I was testing that functionality. Too small fix to warrant a PR of its own.)