Skip to content

[hyperactor] net: zero copy framer #907

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

Open
wants to merge 5 commits into
base: gh/mariusae/42/base
Choose a base branch
from

Conversation

mariusae
Copy link
Member

@mariusae mariusae commented Aug 18, 2025

Stack from ghstack (oldest at bottom):

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.

Differential Revision: D80365228

NOTE FOR REVIEWERS: This PR has internal Meta-specific changes or comments, please review them on Phabricator!

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!

[ghstack-poisoned]
mariusae added a commit that referenced this pull request Aug 18, 2025
This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!

ghstack-source-id: 303699221
Pull Request resolved: #907
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 18, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80365228

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80365228

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!

[ghstack-poisoned]
mariusae added a commit that referenced this pull request Aug 18, 2025
Pull Request resolved: #907

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303752472
@exported-using-ghexport

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80365228

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!

[ghstack-poisoned]
mariusae added a commit that referenced this pull request Aug 18, 2025
Pull Request resolved: #907

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303773787
@exported-using-ghexport

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80365228

shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303773787
exported-using-ghexport

Reviewed By: shayne-fletcher, eliothedeman

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303773787
exported-using-ghexport

Reviewed By: shayne-fletcher, eliothedeman

Differential Revision: D80365228
This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!

[ghstack-poisoned]
mariusae added a commit that referenced this pull request Aug 18, 2025
Pull Request resolved: #907

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
@exported-using-ghexport

Differential Revision: [D80365228](https://our.internmc.facebook.com/intern/diff/D80365228/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D80365228/)!
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80365228

shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:
Pull Request resolved: meta-pytorch#907

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303699221
exported-using-ghexport

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:
Pull Request resolved: meta-pytorch#907

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303699221
exported-using-ghexport

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:
Pull Request resolved: meta-pytorch#907

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303699221
exported-using-ghexport

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
shayne-fletcher pushed a commit to shayne-fletcher/monarch-1 that referenced this pull request Aug 18, 2025
Summary:

This change introduces a zero-copy framer, which will also be easily extendable to doing vectorized framing of multipart messages.

We eschew tokio's framer (which relies on queuing for cancellation safety), in favor of a simple(r) implementation: the reader maintains a simple state machine, while the writer requires the caller to maintain an explicit write state (since this has to be driven across selects in order to be made cancellation safe).

In this way, we have an easily hackable framer that does not introduce additional queues.
ghstack-source-id: 303814000
exported-using-ghexport

Reviewed By: vidhyav

Differential Revision: D80365228
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants