Skip to content
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

Introduce RefUnwindSafe StorageHandle #675

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Feb 6, 2025

David noticed in rust-lang/rust-analyzer#18964 that Storage isn't unwind safe (on a related note it also obviously isn't sync due to the local state). So this is a proposed design at solving this by introducing a non-local state handle (which hence disallows running computations on it). This would allow you to have a non-local state handle, move that across unwind boundaries, threads, etc and once you need todo computations you can turn it into a handle with local state.

In rust-analyzer I would imagine us holding such a non-local state handle in the main global state and whenever we dispatch a request, clone it, move the clone off to the dispatching thread and then materialize it as a local-state hanlde (Storage).

We could directly implement UnwindSafe on Storage (note how we used to implement RefUnwindSafe already, which is the wrong trait at this stage of the setup), given that if we have no references outstanding the query stack will be empty anyways and so we wouldn't run into issues with moving it across an unwind boundary. That doesn't sit quite right with me though so instead I've opted for this setup, as it also feels like a natural extension to the API to me. A side effect of this is that the non-local handle is Sync, though that is likely not too useful as there is no reason to wrap it inside (interior) mutability.

I've added respective RefUnwindSafe implementations where required to make the auto trait impls work as expected with comments explaining the rationale as to why they ought to be correct.

cc @davidbarsky

Copy link

netlify bot commented Feb 6, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 4e44751
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/67ab2ccc81871d0008a5beb2

Copy link

codspeed-hq bot commented Feb 6, 2025

CodSpeed Performance Report

Merging #675 will not alter performance

Comparing Veykril:veykril/push-xsrukmlqwrlm (4e44751) with master (351d9cf)

Summary

✅ 9 untouched benchmarks

@Veykril Veykril force-pushed the veykril/push-xsrukmlqwrlm branch from 25154f7 to 4e44751 Compare February 11, 2025 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant