You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR implements the plan from [RFD
444](https://rfd.shared.oxide.computer/rfd/444#_counter_proposal_one_big_task)
of consolidating all data ownership into a single async task.
It is a squashed commit, but the original commit chain is preserved in the
`one-task-refactoring` tag.
The details are in the RFD, but in short, state is only mutated in one place
(instead of being mutated from multiple tasks). Having a single task own the
`struct Upstairs` means that we don't need to think about locks or cross-task
notifications. This architectural simplification lets us delete almost 3KLOC
while maintaining the same functionality.
The new architecture is event-driven: `Upstairs::select` returns an event, and
`Upstairs::apply` applies that event. We split into two functions for ease of
unit testing; many tests can drive the `Upstairs` by calling `Upstairs::apply`
on a synthetic sequence of events, to put it into a particular state.
Data is stored in a hierarchical set of data structures:
- 1× `Upstairs` has our high-level state and guest-level info. It contains...
- 1× `Downstairs`, which tracks downstairs jobs. It contains...
- 3× `DownstairsClient`, which contain per-client state
Unlike before, each of these data structures is in its own module, meaning its
internal details are private (by default). Tests that need internal details are
often moved into that specific module (e.g. from `test.rs` -> `downstairs.rs`).
This isn't an absolute; in many cases, fields have to be made `pub(crate)` for
ease of testing or cross-layer modification.
I see 20-30% performance improvement for 1M and 4M random-write (`fio`)
benchmarks, compared to `main`. This is likely because the expensive work of
serialization (`FramedWrite`) has moved into a dedicated per-client IO task,
leaving the main task free to keep working.
0 commit comments