-
Notifications
You must be signed in to change notification settings - Fork 175
Optionally force invalidation on cache eviction #853
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
base: master
Are you sure you want to change the base?
Optionally force invalidation on cache eviction #853
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
CodSpeed Performance ReportMerging #853 will not alter performanceComparing Summary
|
f2566af
to
c3d3b11
Compare
How is it different from |
If a cached result is present, it can be reused - whereas |
I don't think what you have here will work. Salsa might backdate your query even if you return changed, in which case the old memo is gonne, but the dependent queries won't rerun (they now all point into the void). Would something similar to our |
I don't think that the
In R2, I still need to recompute D to ensure that it links to the same copy of U as does E. |
Aren't queries only backdated if they are unchanged from their previous/cached value? Here there is no cached value. |
c3d3b11
to
283980e
Compare
Have you tried |
283980e
to
255ffd3
Compare
I don't think I understand this sentence. A query is always considered changed if there was no cached result before. |
AIUI, that impacts whether a newly computed value is considered equal to a cached one—but I am concerned with the situation where there is no cached value. And while this would (as you note) skip backdating, I again don't think backdating is a concern for me, because AIUI it only occurs when there is a cached value to be compared against the newly computed one.
I had understood from the Zulip discussion (linked in the first comment above) that that isn't the case: a query whose inputs are all unchanged would itself be deemed unchanged even if its previous result is no longer in the cache. Indeed, I think this would also be the case if the cached result of a high durability query has been evicted but only low durability inputs have changed: in that case, the query will (shallow) verify as unchanged despite the absence of its cached result. (It's this latter case that my most recent pushes were, erroneously, attempting to address—I'll take a closer look and add some specific tests for this shortly). |
255ffd3
to
4047309
Compare
Can't reproduce this test failure on my machine. It's also super weird, as it's reported to be a failed Smells a bit like UB... but unless But it doesn't appear to be a transient error either, as it has consistently occurred on the last three pushes... and I see that other PRs aren't suffering from it... Will come back to this once I've had some more coffee. |
I've tried reproducing on So this definitely seems to be a rather flaky test. Notably the VM that is closest to the GitHub environment completed the 202 tests in just under 22 seconds, versus the failing GitHub action's 1.2 seconds: and given that these are failures in parallel tests, timing could well be significant. Nevertheless, I'm going to push again and see what happens.... |
4047309
to
b5580ad
Compare
Yeah, okay, it's passing CI now despite no changes. I therefore strongly believe that the failures weren't related to this PR... but it seems likely that there's some preexisting unsoundness somewhere in the project... |
The need for this feature isn't clear enough to me (why does it have to be in Salsa, what are other approaches). I'll leave this for someone else to review. |
Adds a
force_invalidation_on_cache_eviction
option (better naming suggestions most welcome!) to the#[salsa::tracked]
attribute macro, which ensures that a query so marked is always deemed to have changed if there is no cached result present for it in the database—irrespective of its inputs' validity. Consequently downstream queries will be recomputed.This is necessary if such downstream queries might hold pointers into a query's cached result. Such pointers would be invalidated by cache eviction, even if the query's inputs are unchanged (and therefore any recomputed result will be unchanged: a situation which typically does not cause recomputation of downstream queries).
My use-case is in the codegen backend of a JIT compiler. Suppose a query returns the (unlinked) object code for a given translation unit. A program may contain many such translation units, whose object code must be linked together through a relocation step: we therefore might have a second query that returns the now-linked object code for a given translation unit. However, such links into other translation units' object code would be invalidated by the eviction of that object code from the cache. We need to ensure that, in such a case, the second query is re-run for the dependent translation unit so that its object code gets correctly linked to the current revision's freshly recalculated object code for that dependency.
This arose from a brief discussion on Zulip. cc @Veykril