Skip to content

Improve design of rust global shared state#2373

Merged
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:global-refcell
Aug 23, 2022
Merged

Improve design of rust global shared state#2373
stevenengler merged 2 commits intoshadow:mainfrom
stevenengler:global-refcell

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

  • wraps the global shared state (WORKER_SHARED) in an AtomicRefCell so that we can drop the state when the simulation ends
  • adds a borrowed reference to the shared global state to the thread-local global state (WORKER) to reverse any performance impact caused by the AtomicRefCell

@stevenengler stevenengler added the Component: Main Composing the core Shadow executable label Aug 23, 2022
@stevenengler stevenengler self-assigned this Aug 23, 2022
This allows us to drop everything in the global state when the simulation is
done.
Instead of requiring two atomic reads to access `WORKER_SHARED` (one for
`Lazy::deref` and another for `AtomicRefCell::borrow` in `WorkerShared`), we
only need one atomic read (one for `Lazy::deref` in `Worker`).
@stevenengler stevenengler enabled auto-merge August 23, 2022 23:10
@stevenengler stevenengler merged commit dd9db00 into shadow:main Aug 23, 2022
@stevenengler stevenengler deleted the global-refcell branch August 23, 2022 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Main Composing the core Shadow executable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants