Repository navigation
fix(qmux)!: enforce datagram policy and hide transport mutators #7256
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d776066
chore(quest): claim quest/m1/api-audit/qmux-datagrams.md
kixelated 0e8bdc6
fix(qmux)!: enforce datagram policy and hide transport mutators
kixelated cc60e4f
Merge remote-tracking branch 'origin/main' into enforce-datagram-policy
kixelated 8171486
fix(qmux): run the datagram backlog bench nightly and finish the quest
kixelated 0daa498
Merge remote-tracking branch 'origin/main' into enforce-datagram-policy
kixelated ec9560c
Merge remote-tracking branch 'origin/main' into quest/m1/api-audit/qm…
kixelated 77e8d64
quest land: merge tested base
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /** Sweep receive-queue draining over backlog size through the public session API. */ | ||
| import * as Frame from "../src/frame.ts"; | ||
| import Session from "../src/session.ts"; | ||
| import type { WebSocketStreamCloseEvent } from "../src/web-socket-stream.ts"; | ||
|
|
||
| const packet = Frame.encode({ type: "datagram", data: new Uint8Array(1200) }, "qmux-01"); | ||
|
|
||
| async function measure(backlog: number): Promise<number> { | ||
| let incoming!: ReadableStreamDefaultController<Uint8Array>; | ||
| const pong = Promise.withResolvers<void>(); | ||
| const closed = Promise.withResolvers<WebSocketStreamCloseEvent>(); | ||
| const session = Session.accept( | ||
| { | ||
| url: "https://example.test/qmux-bench", | ||
| opened: Promise.resolve({ | ||
| protocol: "qmux-01", | ||
| extensions: "", | ||
| readable: new ReadableStream<Uint8Array>({ | ||
| start: (controller) => { | ||
| incoming = controller; | ||
| }, | ||
| }), | ||
| writable: new WritableStream<Uint8Array>({ | ||
| write: (bytes) => { | ||
| if (Frame.decodeRecord(bytes).some((frame) => frame.type === "ping_response")) pong.resolve(); | ||
| }, | ||
| }), | ||
| }), | ||
| closed: closed.promise, | ||
| close: () => closed.resolve({ closeCode: 1000, reason: "" }), | ||
| }, | ||
| { config: { idleTimeout: null } }, | ||
| ); | ||
| await session.ready; | ||
| session.datagrams.incomingHighWaterMark = backlog; | ||
| for (let index = 0; index < backlog; index++) incoming.enqueue(packet); | ||
| incoming.enqueue(Frame.encode({ type: "ping_request", sequence: 0n }, "qmux-01")); | ||
| await pong.promise; | ||
| const reader = session.datagrams.readable.getReader(); | ||
| const start = performance.now(); | ||
| for (let index = 0; index < backlog; index++) { | ||
| const result = await reader.read(); | ||
| if (result.done || result.value.byteLength !== 1200) throw new Error("missing datagram"); | ||
| } | ||
| const elapsed = ((performance.now() - start) * 1000) / backlog; | ||
| await reader.cancel(); | ||
| session.close(); | ||
| await closed.promise; | ||
| return elapsed; | ||
| } | ||
|
|
||
| console.log("backlog,us_per_read"); | ||
| for (const backlog of [1, 32, 1024, 16384]) { | ||
| const samples: number[] = []; | ||
| for (let run = 0; run < 7; run++) samples.push(await measure(backlog)); | ||
| samples.sort((a, b) => a - b); | ||
| console.log(`${backlog},${samples[3].toFixed(3)}`); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify the nonnegative range that is clamped.
“Values below 1 are clamped to 1” includes negative values, but the next sentence says negative values throw
RangeError. The setter rejects negative values before applying the clamp. (raw.githubusercontent.com)Change this to “Nonnegative values below 1 are clamped to 1.”