-
Couldn't load subscription status.
- Fork 190
Introduce a CancellationToken for cancelling specific computations
#1007
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?
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
CodSpeed Performance ReportMerging #1007 will degrade performances by 9.87%Comparing Summary
Benchmarks breakdown
|
|
Looks like allocator noise from the new arc alloc |
|
Interesting. Is the idea to cancel a single thread rather than all threads? Won't this cancell all threads that currently block on any query executing on the thread being cancelled? |
Yes, the thought is that this could allow implementing client side request cancellation for LSP requests for example.
That is the thing I will have to investigate. We unwind with the payload, we don't panic so I believe this does not set the panicking state of the thread actually. So this might actually just work (though I doubt it). |
Oh, so other threads would reclaim and re-execute the queries then. Interesting. |
|
That would be the ideal I think |
db715b7 to
47b7a7d
Compare
|
I was wrong, unwinding does set the panicking flag after all (which probably makes more sense ...) hmm |
f97346e to
de32cab
Compare
ba0f832 to
2318de4
Compare
|
Would mind explaining the approach in the pr summary. I'm mainly interested in how it works if other threads are blocked on a query that gets cancelled (including if they participate in a cycle) |
d0fee43 to
d2edc9b
Compare
d2edc9b to
e0ad0ff
Compare
|
Turns out I forgot to actually implemen the relevant retry part before 🤦 I did add the bool return type but didn't fix up the usages. To my surprise my test I added worked either way, which I think makes sense? Even if we don't retry if we don't propagate the panic we will just notice the value still missing in fetch cold and recompute again. Though I think this will cause two databases to compute the same query if they both were blocked. Should probably add a test for that. Likewise I am not yet sure how to handle this for fix points yet (and need to cook up a test there as well) |
Introduces a
CancellationTokenthat can be used to cancel a specific database computation opposed to cancelling the whole runtime. This is traced by storing a second cancellation state onZalsaLocalitself opposed to the runtime cancel flag.When a thread gets cancelled, it will unwind as usual but with a different payload than pending write cancellation, threads blocked on such a cancelled thread will instead of propagating the cancellation run the computation they are blocked on themselves.
The cancellation state of the database gets reset when we exit the database TLS.