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

[catnap] Move states and YielderHandle allocation into CatnapQueue #857

Merged
merged 6 commits into from
Aug 4, 2023

Conversation

iyzhang
Copy link
Contributor

@iyzhang iyzhang commented Jul 29, 2023

This PR moves the Catnap libOS towards our eventual architecture. There are a few important steps that this PR implements:

  1. The CatnapLibOS now only contains cross-queue functionality and no state. It is never referred to through a mutable reference.
  2. All libOS level state is contained in the runtime and qtable, which will eventually move to the runtime. It is dynamically borrowed at runtime.
  3. The CatnapQueue only contains single-queue functionality and no state. It is never referred to through a mutable reference.
  4. All queue level state is kept in the platform-specific Socket data structure. It is dynamically borrowed at runtime.
  5. All asynchronous operations are broken up into two functions at both the libOS level and the queue level: one function for synchronous functionality and another for asynchronous functionality.

After this PR the following guidelines are recommended for our architecture:

  1. Never use mut on stateless objects, specifically the libOS and queue structures. We should never pass &mut self for those.
  2. State should be contained in platform-specific abstractions because generally the state that needs to be kept is platform-specific. The exceptions to these are the list of pending ops per queue and the SocketStateMachine, which are shared across libOSes and platforms.
  3. All functionality for every call should be divided by whether the code operates on a single queue or more than one queue. All single-queue code shall be placed in the Cat*Queue class and all multi-queue code shall be placed in the Cat*LibOS class.
  4. All asynchronous calls must be further divided into synchronous operations and asynchronous operations and placed in respective functions.
  5. At the libOS level, there should be no state outside of the queue table (and a platform-specific backmap of addresses to queues). This state will eventually be kept in a shared runtime. If there are exceptions, they should undergo an architectural review.
  6. Only asynchronous functions can block and only if they take in a yielder. Always separate synchronous and asynchronous code into two functions.

@iyzhang iyzhang self-assigned this Jul 29, 2023
@iyzhang iyzhang added the enhancement Enhancement Request on an Existing Feature label Jul 29, 2023
@iyzhang iyzhang force-pushed the enhancement-catnap-queue-reorg branch from 2e2e022 to b75b201 Compare July 29, 2023 23:45
@iyzhang iyzhang changed the title [catnap] Enhancement: Re-architecture [catnap] Enhancement: Move states and YielderHandle allocation into CatnapQueue Jul 30, 2023
@iyzhang iyzhang force-pushed the enhancement-catnap-queue-reorg branch from b75b201 to 79cf8bd Compare July 30, 2023 00:47
@ppenna ppenna changed the title [catnap] Enhancement: Move states and YielderHandle allocation into CatnapQueue [catnap] Move states and YielderHandle allocation into CatnapQueue Jul 31, 2023
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
src/rust/catnap/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@anandbonde anandbonde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments.

@ppenna ppenna force-pushed the enhancement-catnap-queue-reorg branch from 79cf8bd to f84e864 Compare August 4, 2023 16:59
@ppenna ppenna force-pushed the enhancement-catnap-queue-reorg branch from f84e864 to 941bd61 Compare August 4, 2023 18:34
@anandbonde anandbonde self-requested a review August 4, 2023 18:41
Copy link
Contributor

@anandbonde anandbonde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@ppenna ppenna merged commit a7d73ab into dev Aug 4, 2023
11 checks passed
@ppenna ppenna deleted the enhancement-catnap-queue-reorg branch August 4, 2023 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement Request on an Existing Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants