From f85f2865482347c11db7d98e046330a29fc636f8 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 23:47:18 -0700 Subject: [PATCH 1/3] quest: claim quest/m1/audit-size Co-Authored-By: Claude Opus 5.5 From 1d784712457c7bb95c135cc52d40c73e4dcb1450 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 20 Oct 2026 23:53:18 -0700 Subject: [PATCH 2/3] perf(net): keep the IETF message parameter codec out of the first load SETUP options move from ietf/parameters.ts to ietf/setup_options.ts, with the MAX_REQUEST_ID window from ietf/request.ts, and the MoQ Cluster helpers fill a caller's parameter block instead of constructing one. The eager SETUP surface no longer reaches the message parameter codec or the filter module, which only a session uses. First load drops about 5.1 to 5.5 KB gzip in every consumer bundle; ietf/index.test.ts fails if SETUP reaches parameters.ts again. Co-Authored-By: Claude Opus 5.5 --- js/net/src/ietf/active_count.ts | 2 +- js/net/src/ietf/adapter.test.ts | 3 +- js/net/src/ietf/adapter.ts | 3 +- js/net/src/ietf/auth.test.ts | 2 +- js/net/src/ietf/auth_setup.ts | 2 +- js/net/src/ietf/cluster.test.ts | 25 +-- js/net/src/ietf/cluster.ts | 19 +-- js/net/src/ietf/connection.test.ts | 5 +- js/net/src/ietf/epoch.test.ts | 3 +- js/net/src/ietf/epoch.ts | 2 +- js/net/src/ietf/hidden.ts | 2 +- js/net/src/ietf/ietf.test.ts | 3 +- js/net/src/ietf/index.test.ts | 5 +- js/net/src/ietf/index.ts | 3 +- js/net/src/ietf/malformed.test.ts | 2 +- js/net/src/ietf/max-age.test.ts | 3 +- js/net/src/ietf/max_age.ts | 2 +- js/net/src/ietf/parameters.ts | 197 ------------------------ js/net/src/ietf/publish_namespace.ts | 6 +- js/net/src/ietf/request.ts | 19 --- js/net/src/ietf/setup.ts | 2 +- js/net/src/ietf/setup_options.ts | 219 +++++++++++++++++++++++++++ js/net/src/ietf/solicit.test.ts | 2 +- js/net/src/ietf/solicit.ts | 2 +- js/net/src/ietf/token.test.ts | 3 +- js/net/src/ietf/token.ts | 3 +- 26 files changed, 279 insertions(+), 260 deletions(-) create mode 100644 js/net/src/ietf/setup_options.ts diff --git a/js/net/src/ietf/active_count.ts b/js/net/src/ietf/active_count.ts index 361d98c9777..02882a8730c 100644 --- a/js/net/src/ietf/active_count.ts +++ b/js/net/src/ietf/active_count.ts @@ -1,4 +1,4 @@ -import { SetupOption, type SetupOptions } from "./parameters.ts"; +import { SetupOption, type SetupOptions } from "./setup_options.ts"; import { type IetfVersion, Version } from "./version.ts"; /** diff --git a/js/net/src/ietf/adapter.test.ts b/js/net/src/ietf/adapter.test.ts index b633331b12d..cbd1ad88b7a 100644 --- a/js/net/src/ietf/adapter.test.ts +++ b/js/net/src/ietf/adapter.test.ts @@ -12,7 +12,8 @@ import { PublishNamespaceDone, PublishNamespaceUpdate, } from "./publish_namespace.ts"; -import { initialMaxRequestId, MaxRequestId, REQUEST_WINDOW, RequestError, RequestOk } from "./request.ts"; +import { MaxRequestId, RequestError, RequestOk } from "./request.ts"; +import { initialMaxRequestId, REQUEST_WINDOW } from "./setup_options.ts"; import { Subscribe, SubscribeUpdate } from "./subscribe.ts"; import { SubscribeNamespaceLegacy } from "./subscribe_namespace.ts"; import { TrackStatusRequest } from "./track.ts"; diff --git a/js/net/src/ietf/adapter.ts b/js/net/src/ietf/adapter.ts index 52a93d8ef0f..048eb4f0b6d 100644 --- a/js/net/src/ietf/adapter.ts +++ b/js/net/src/ietf/adapter.ts @@ -7,8 +7,9 @@ import { untilAborted } from "../util/abort.ts"; import * as Varint from "../varint.ts"; import { GoAway } from "./goaway.ts"; import * as Namespace from "./namespace.ts"; -import { initialMaxRequestId, MaxRequestId, REQUEST_WINDOW } from "./request.ts"; +import { MaxRequestId } from "./request.ts"; import { refuseUpdate } from "./request_stream.ts"; +import { initialMaxRequestId, REQUEST_WINDOW } from "./setup_options.ts"; import { type IetfVersion, Version } from "./version.ts"; /** The peer used a request ID the draft closes the session for. */ diff --git a/js/net/src/ietf/auth.test.ts b/js/net/src/ietf/auth.test.ts index 9286d9eb029..d5883a170a5 100644 --- a/js/net/src/ietf/auth.test.ts +++ b/js/net/src/ietf/auth.test.ts @@ -5,7 +5,7 @@ import * as Path from "../path.ts"; import { Reader, Writer } from "../stream.ts"; import { AuthError, AuthMessage, AuthOk } from "./auth.ts"; import { fromSetup, intoSetup } from "./auth_setup.ts"; -import { SetupOption, SetupOptions } from "./parameters.ts"; +import { SetupOption, SetupOptions } from "./setup_options.ts"; import { Version } from "./version.ts"; function patterns(...prefixes: string[]): Path.Patterns { diff --git a/js/net/src/ietf/auth_setup.ts b/js/net/src/ietf/auth_setup.ts index 4d9e976aafd..22fd2c304c7 100644 --- a/js/net/src/ietf/auth_setup.ts +++ b/js/net/src/ietf/auth_setup.ts @@ -1,4 +1,4 @@ -import { SetupOption, type SetupOptions } from "./parameters.ts"; +import { SetupOption, type SetupOptions } from "./setup_options.ts"; import { type IetfVersion, Version } from "./version.ts"; /** diff --git a/js/net/src/ietf/cluster.test.ts b/js/net/src/ietf/cluster.test.ts index 4e57148b180..85aadcec338 100644 --- a/js/net/src/ietf/cluster.test.ts +++ b/js/net/src/ietf/cluster.test.ts @@ -6,8 +6,9 @@ import { Reader, Writer } from "../stream.ts"; import * as Cluster from "./cluster.ts"; import * as Message from "./message.ts"; import * as Namespace from "./namespace.ts"; -import { Parameters, SetupOption, SetupOptions } from "./parameters.ts"; +import { Parameters } from "./parameters.ts"; import { PublishNamespace, PublishNamespaceUpdate } from "./publish_namespace.ts"; +import { SetupOption, SetupOptions } from "./setup_options.ts"; import { SubscribeNamespaceEntry } from "./subscribe_namespace.ts"; import { MalformedAuthToken } from "./token.ts"; import { type IetfVersion, Version } from "./version.ts"; @@ -51,6 +52,12 @@ async function encode { test("Cluster: the hop path carries no count of its own", async () => { // The entries fill the parameter length; a count would make us unreadable to every // other implementation. - const params = Cluster.intoParams({ hops: hops(1n, 2n, 3n), cost: 0n }); + const params = intoParams({ hops: hops(1n, 2n, 3n), cost: 0n }); expect(Array.from(await encode(params))).toEqual([ 0x01, // parameter count 0xc4, @@ -83,14 +90,14 @@ test("Cluster: the hop path carries no count of its own", async () => { test("Cluster: an advertisement round trips through the parameters", async () => { const advert = { hops: hops(7n, 9n), cost: 5n }; - const encoded = await encode(Cluster.intoParams(advert)); + const encoded = await encode(intoParams(advert)); const decoded = await Parameters.decode(reader(encoded), VERSION); expect(Cluster.fromParams(decoded)).toEqual(advert); }); test("Cluster: a zero route cost is absent from the wire", async () => { - const free = await encode(Cluster.intoParams({ hops: hops(7n), cost: 0n })); - const priced = await encode(Cluster.intoParams({ hops: hops(7n), cost: 1n })); + const free = await encode(intoParams({ hops: hops(7n), cost: 0n })); + const priced = await encode(intoParams({ hops: hops(7n), cost: 1n })); expect(free.length).toBeLessThan(priced.length); // Absent means 0, so it comes back as one. @@ -100,7 +107,7 @@ test("Cluster: a zero route cost is absent from the wire", async () => { test("Cluster: a repeated zero is not a loop", async () => { const advert = { hops: hops(0n, 5n, 0n), cost: 0n }; - const encoded = await encode(Cluster.intoParams(advert)); + const encoded = await encode(intoParams(advert)); const decoded = await Parameters.decode(reader(encoded), VERSION); expect(Cluster.fromParams(decoded)).toEqual(advert); }); @@ -119,7 +126,7 @@ test("Cluster: a malformed advertisement is a session-fatal violation", () => { test("Cluster: a path that cannot have come from a conforming sender is rejected", () => { // A non-zero id appearing twice is a loop. - expect(() => Cluster.intoParams({ hops: hops(4n, 8n, 4n), cost: 0n })).toThrow(); + expect(() => intoParams({ hops: hops(4n, 8n, 4n), cost: 0n })).toThrow(); // The list always has at least one entry: the original publisher. const empty = new Parameters(); @@ -137,7 +144,7 @@ test("Cluster: a path that cannot have come from a conforming sender is rejected // Longer than we accept, which a real path never is and a loop is. const long = Array.from({ length: 33 }, (_, i) => origin(BigInt(i + 1))); - expect(() => Cluster.intoParams({ hops: long, cost: 0n })).toThrow(); + expect(() => intoParams({ hops: long, cost: 0n })).toThrow(); }); test("Cluster: the setup options round trip", async () => { @@ -250,7 +257,7 @@ test("Cluster: a negotiated PUBLISH_NAMESPACE may carry AUTHORIZATION_TOKEN", as await Message.encode(w, async (wr) => { await wr.u62(1n); await Namespace.encode(wr, Path.from("alice.hang")); - const params = Cluster.intoParams(advert); + const params = intoParams(advert); params.bytes.set(0x03n, new Uint8Array([0x03, 0x00, 0xaa])); // AUTHORIZATION_TOKEN: USE_VALUE, type 0 await params.encode(wr, version); }); diff --git a/js/net/src/ietf/cluster.ts b/js/net/src/ietf/cluster.ts index 092264f3c87..b785f0035d4 100644 --- a/js/net/src/ietf/cluster.ts +++ b/js/net/src/ietf/cluster.ts @@ -27,7 +27,9 @@ import { ProtocolViolation, reason } from "../error.ts"; import { type Hop, HopSchema, MAX_HOPS, UNKNOWN_HOP } from "../hop.ts"; import * as Varint from "../varint.ts"; -import { Parameters, SetupOption, type SetupOptions } from "./parameters.ts"; +// Type-only: SETUP loads eagerly and must not pull in the message parameter codec. +import type { Parameters } from "./parameters.ts"; +import { SetupOption, type SetupOptions } from "./setup_options.ts"; import { type IetfVersion, Version } from "./version.ts"; /** @@ -160,31 +162,26 @@ export function loops(advert: Advert, self: Hop): boolean { } /** - * Write an advertisement's parameters, ready to encode onto the wire. + * Write an advertisement's parameters into `params`, ready to encode onto the wire. * * @internal */ -export function intoParams(advert: Advert): Parameters { - const params = new Parameters(); +export function intoParams(advert: Advert, params: Parameters) { params.hopPath = encodeHops(advert.hops); // Absent means 0, so a free path sends nothing. if (advert.cost !== 0n) params.routeCost = advert.cost; - - return params; } /** - * Write a REQUEST_UPDATE's parameters: only what changed, and a cost of 0 explicitly, - * since an omitted parameter keeps its value. + * Write a REQUEST_UPDATE's parameters into `params`: only what changed, and a cost of 0 + * explicitly, since an omitted parameter keeps its value. * * @internal */ -export function updateIntoParams(update: Update): Parameters { - const params = new Parameters(); +export function updateIntoParams(update: Update, params: Parameters) { if (update.hops !== undefined) params.hopPath = encodeHops(update.hops); if (update.cost !== undefined) params.routeCost = update.cost; - return params; } /** Write a HOP_PATH value: the entries fill it with no count of their own, framed by the diff --git a/js/net/src/ietf/connection.test.ts b/js/net/src/ietf/connection.test.ts index 1c54d928812..d9890650627 100644 --- a/js/net/src/ietf/connection.test.ts +++ b/js/net/src/ietf/connection.test.ts @@ -11,9 +11,10 @@ import { Connection } from "./connection.ts"; import * as Message from "./message.ts"; import * as Namespace from "./namespace.ts"; import { Group } from "./object.ts"; -import { Parameters, SetupOption, SetupOptions } from "./parameters.ts"; -import { initialMaxRequestId, MaxRequestId, RequestError, RequestOk } from "./request.ts"; +import { Parameters } from "./parameters.ts"; +import { MaxRequestId, RequestError, RequestOk } from "./request.ts"; import { Setup } from "./setup.ts"; +import { initialMaxRequestId, SetupOption, SetupOptions } from "./setup_options.ts"; import { SubscribeError, SubscribeOk } from "./subscribe.ts"; import { SUBSCRIBE_TRACKS_ID, diff --git a/js/net/src/ietf/epoch.test.ts b/js/net/src/ietf/epoch.test.ts index 9af26ceff0d..1c5f643a043 100644 --- a/js/net/src/ietf/epoch.test.ts +++ b/js/net/src/ietf/epoch.test.ts @@ -8,8 +8,9 @@ import type * as Cluster from "./cluster.ts"; import * as EpochExt from "./epoch.ts"; import { Fetch } from "./fetch.ts"; import * as Message from "./message.ts"; -import { Parameters, SetupOption, SetupOptions } from "./parameters.ts"; +import { Parameters } from "./parameters.ts"; import { type AdvertParams, PublishNamespace } from "./publish_namespace.ts"; +import { SetupOption, SetupOptions } from "./setup_options.ts"; import { Subscribe } from "./subscribe.ts"; import { SubscribeNamespaceEntry } from "./subscribe_namespace.ts"; import { TrackStatusRequest } from "./track.ts"; diff --git a/js/net/src/ietf/epoch.ts b/js/net/src/ietf/epoch.ts index eb774415766..4e26bd45846 100644 --- a/js/net/src/ietf/epoch.ts +++ b/js/net/src/ietf/epoch.ts @@ -1,4 +1,4 @@ -import { SetupOption, type SetupOptions } from "./parameters.ts"; +import { SetupOption, type SetupOptions } from "./setup_options.ts"; import { type IetfVersion, Version } from "./version.ts"; /** diff --git a/js/net/src/ietf/hidden.ts b/js/net/src/ietf/hidden.ts index ea732799303..211d697c09d 100644 --- a/js/net/src/ietf/hidden.ts +++ b/js/net/src/ietf/hidden.ts @@ -1,4 +1,4 @@ -import { SetupOption, type SetupOptions } from "./parameters.ts"; +import { SetupOption, type SetupOptions } from "./setup_options.ts"; /** * The MoQ Hidden extension (draft-lcurley-moq-hidden-00). diff --git a/js/net/src/ietf/ietf.test.ts b/js/net/src/ietf/ietf.test.ts index f8eb985e04a..475f3fe4447 100644 --- a/js/net/src/ietf/ietf.test.ts +++ b/js/net/src/ietf/ietf.test.ts @@ -8,11 +8,12 @@ import { Fetch } from "./fetch.ts"; import * as GoAway from "./goaway.ts"; import * as Namespace from "./namespace.ts"; import { FetchFrame, type FetchPosition, Frame, Group, type GroupFlags } from "./object.ts"; -import { Parameters, SetupOptions } from "./parameters.ts"; +import { Parameters } from "./parameters.ts"; import { Publish, PublishDone } from "./publish.ts"; import * as Announce from "./publish_namespace.ts"; import { RequestError, RequestOk } from "./request.ts"; import * as Setup from "./setup.ts"; +import { SetupOptions } from "./setup_options.ts"; import * as Subscribe from "./subscribe.ts"; import * as SubscribeNamespace from "./subscribe_namespace.ts"; import * as Track from "./track.ts"; diff --git a/js/net/src/ietf/index.test.ts b/js/net/src/ietf/index.test.ts index e70691571f1..3d4436c7e4c 100644 --- a/js/net/src/ietf/index.test.ts +++ b/js/net/src/ietf/index.test.ts @@ -18,5 +18,8 @@ test("the package entry loads the IETF session code on demand", async () => { const eager = [...reached].map((file) => relative(src, file)); expect(eager).toContain("ietf/setup.ts"); - for (const lazy of ["ietf/connection.ts", "ietf/request_stream.ts"]) expect(eager).not.toContain(lazy); + // SETUP shares no module with the message parameter codec, which only a session uses. + for (const lazy of ["ietf/connection.ts", "ietf/request_stream.ts", "ietf/parameters.ts"]) { + expect(eager).not.toContain(lazy); + } }); diff --git a/js/net/src/ietf/index.ts b/js/net/src/ietf/index.ts index c820119cab3..2d4208134ff 100644 --- a/js/net/src/ietf/index.ts +++ b/js/net/src/ietf/index.ts @@ -6,9 +6,8 @@ export * as Cluster from "./cluster.ts"; export * as Epoch from "./epoch.ts"; export * from "./hidden.ts"; export * from "./max_age.ts"; -export * from "./parameters.ts"; -export { initialMaxRequestId } from "./request.ts"; export * from "./setup.ts"; +export * from "./setup_options.ts"; export * from "./solicit.ts"; export * from "./token.ts"; export * from "./version.ts"; diff --git a/js/net/src/ietf/malformed.test.ts b/js/net/src/ietf/malformed.test.ts index 6ba8a02ceca..aec12bb2d75 100644 --- a/js/net/src/ietf/malformed.test.ts +++ b/js/net/src/ietf/malformed.test.ts @@ -9,9 +9,9 @@ import { Stream, Writer } from "../stream.ts"; import { Timescale } from "../time.ts"; import { Connection } from "./connection.ts"; import { GoAway } from "./goaway.ts"; -import { SetupOption, SetupOptions } from "./parameters.ts"; import { RequestOk } from "./request.ts"; import { Setup } from "./setup.ts"; +import { SetupOption, SetupOptions } from "./setup_options.ts"; import { SubscribeOk } from "./subscribe.ts"; import { SUBSCRIBE_TRACKS_ID, SubscribeNamespace } from "./subscribe_namespace.ts"; import { ALPN, type IetfVersion, Version } from "./version.ts"; diff --git a/js/net/src/ietf/max-age.test.ts b/js/net/src/ietf/max-age.test.ts index 0d16e303d4b..54d3457666c 100644 --- a/js/net/src/ietf/max-age.test.ts +++ b/js/net/src/ietf/max-age.test.ts @@ -2,7 +2,8 @@ import { expect, test } from "bun:test"; import * as Path from "../path.ts"; import { Reader, Writer } from "../stream.ts"; import { maxAgeFromSetup, maxAgeIntoSetup } from "./max_age.ts"; -import { Parameters, SetupOptions } from "./parameters.ts"; +import { Parameters } from "./parameters.ts"; +import { SetupOptions } from "./setup_options.ts"; import { Subscribe, SubscribeOk, SubscribeUpdate } from "./subscribe.ts"; import { type IetfVersion, Version } from "./version.ts"; diff --git a/js/net/src/ietf/max_age.ts b/js/net/src/ietf/max_age.ts index 5601c0a67d1..abd9730b437 100644 --- a/js/net/src/ietf/max_age.ts +++ b/js/net/src/ietf/max_age.ts @@ -1,5 +1,5 @@ /** Subscriber age budgets from the MoQ Timestamp extension. @module @internal */ -import { SetupOption, type SetupOptions } from "./parameters.ts"; +import { SetupOption, type SetupOptions } from "./setup_options.ts"; /** The negotiated max-age Setup Option. @internal */ export const MAX_AGE_OPTION = SetupOption.MaxAge; diff --git a/js/net/src/ietf/parameters.ts b/js/net/src/ietf/parameters.ts index 293e6ed1f4c..1f3dcc84ffc 100644 --- a/js/net/src/ietf/parameters.ts +++ b/js/net/src/ietf/parameters.ts @@ -8,203 +8,6 @@ import * as Namespace from "./namespace.ts"; import { AUTHORIZATION_TOKEN, type Token, tokenFromRequest, unique } from "./token.ts"; import { type IetfVersion, Version } from "./version.ts"; -/// Setup Option key constants (separate namespace from Message Parameters). -export const SetupOption = { - Path: 1n, - MaxRequestId: 2n, - AuthorizationToken: AUTHORIZATION_TOKEN, - MaxAuthTokenCacheSize: 4n, - Authority: 5n, - Implementation: 7n, - /** HOP_ID, from the MoQ Cluster extension. See `cluster.ts`. */ - HopId: 0x40b54n, - /** RELAY_COST, from the MoQ Cluster extension. See `cluster.ts`. */ - RelayCost: 0x40b56n, - /** SOLICIT, from the MoQ Solicit extension. See `solicit.ts`. */ - Solicit: 0x40b5an, - /** HIDDEN, from the MoQ Hidden extension. See `hidden.ts`. */ - Hidden: 0x40b5cn, - /** Subscriber max age, from the MoQ Timestamp extension. */ - MaxAge: 0x915c4n, - /** AUTH, from the MoQ Auth extension. See `auth.ts`. */ - Auth: 0x40b60n, - /** ACTIVE_COUNT, from the MoQ Active Count extension. See `active_count.ts`. */ - ActiveCount: 0x40b64n, - /** EPOCH, from the MoQ Epoch extension. See `epoch.ts`. */ - Epoch: 0x40b68n, -} as const; - -// Unknown SETUP options may repeat, including GREASE (draft-21 section 9.1). -const KNOWN_SETUP_OPTIONS: readonly bigint[] = Object.values(SetupOption); - -/// Setup Options — used in SETUP messages. -/// -/// In d14-d16 these are count-prefixed ("Setup Parameters"). -/// In d17 these have no count prefix ("Setup Options") and read/write to end of message. -export class SetupOptions { - vars: Map; - bytes: Map; - - constructor() { - this.vars = new Map(); - this.bytes = new Map(); - } - - get size() { - return this.vars.size + this.bytes.size; - } - - setBytes(id: bigint, value: Uint8Array) { - if (id % 2n !== 1n) { - throw new Error(`invalid parameter id: ${id.toString()}, must be odd`); - } - this.bytes.set(id, value); - } - - setVarint(id: bigint, value: bigint) { - if (id % 2n !== 0n) { - throw new Error(`invalid parameter id: ${id.toString()}, must be even`); - } - this.vars.set(id, value); - } - - getBytes(id: bigint): Uint8Array | undefined { - if (id % 2n !== 1n) { - throw new Error(`invalid parameter id: ${id.toString()}, must be odd`); - } - return this.bytes.get(id); - } - - getVarint(id: bigint): bigint | undefined { - if (id % 2n !== 0n) { - throw new Error(`invalid parameter id: ${id.toString()}, must be even`); - } - return this.vars.get(id); - } - - removeBytes(id: bigint): boolean { - if (id % 2n !== 1n) { - throw new Error(`invalid parameter id: ${id.toString()}, must be odd`); - } - return this.bytes.delete(id); - } - - removeVarint(id: bigint): boolean { - if (id % 2n !== 0n) { - throw new Error(`invalid parameter id: ${id.toString()}, must be even`); - } - return this.vars.delete(id); - } - - async encode(w: Writer, version: IetfVersion) { - if (version !== Version.DRAFT_14 && version !== Version.DRAFT_15) { - // d17+: no count prefix; d16: count prefix - if (version === Version.DRAFT_16) { - await w.u53(this.vars.size + this.bytes.size); - } - - // Delta encoding: collect all keys, sort, encode deltas - const all: { key: bigint; isVar: boolean }[] = []; - for (const id of this.vars.keys()) all.push({ key: id, isVar: true }); - for (const id of this.bytes.keys()) all.push({ key: id, isVar: false }); - all.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)); - - let prevId = 0n; - for (let i = 0; i < all.length; i++) { - const { key, isVar } = all[i]; - const delta = i === 0 ? key : key - prevId; - prevId = key; - await w.u62(delta); - - if (isVar) { - // biome-ignore lint/style/noNonNullAssertion: key is guaranteed to exist in vars map - await w.u62(this.vars.get(key)!); - } else { - // biome-ignore lint/style/noNonNullAssertion: key is guaranteed to exist in bytes map - const value = this.bytes.get(key)!; - await w.u53(value.length); - await w.write(value); - } - } - } else { - await w.u53(this.vars.size + this.bytes.size); - - for (const [id, value] of this.vars) { - await w.u62(id); - await w.u62(value); - } - - for (const [id, value] of this.bytes) { - await w.u62(id); - await w.u53(value.length); - await w.write(value); - } - } - } - - static async decode(r: Reader, version: IetfVersion): Promise { - const params = new SetupOptions(); - - if (version !== Version.DRAFT_14 && version !== Version.DRAFT_15 && version !== Version.DRAFT_16) { - // d17+: no count prefix, read until reader is done - let prevType = 0n; - let i = 0; - while (!(await r.done())) { - const delta = await r.u62(); - const id = i === 0 ? delta : prevType + delta; - prevType = id; - i++; - - if (id % 2n === 0n) { - if (KNOWN_SETUP_OPTIONS.includes(id) && params.vars.has(id)) { - throw new Error(`duplicate parameter id: ${id.toString()}`); - } - const varint = await r.u62(); - params.setVarint(id, varint); - } else { - if (KNOWN_SETUP_OPTIONS.includes(id) && params.bytes.has(id)) { - throw new Error(`duplicate parameter id: ${id.toString()}`); - } - const size = await r.u53(); - const bytes = await r.read(size); - params.setBytes(id, bytes); - } - } - } else { - const count = await r.u53(); - let prevType = 0n; - - for (let i = 0; i < count; i++) { - let id: bigint; - if (version === Version.DRAFT_16) { - const delta = await r.u62(); - id = i === 0 ? delta : prevType + delta; - prevType = id; - } else { - id = await r.u62(); - } - - if (id % 2n === 0n) { - if (KNOWN_SETUP_OPTIONS.includes(id) && params.vars.has(id)) { - throw new Error(`duplicate parameter id: ${id.toString()}`); - } - const varint = await r.u62(); - params.setVarint(id, varint); - } else { - if (KNOWN_SETUP_OPTIONS.includes(id) && params.bytes.has(id)) { - throw new Error(`duplicate parameter id: ${id.toString()}`); - } - const size = await r.u53(); - const bytes = await r.read(size); - params.setBytes(id, bytes); - } - } - } - - return params; - } -} - // ---- Message Parameters (used in Subscribe, Publish, Fetch, etc.) ---- // Count-prefixed KVPs through d16, then definition-specific Type-Value pairs. // Parameter types are delta-encoded from d16 onward. diff --git a/js/net/src/ietf/publish_namespace.ts b/js/net/src/ietf/publish_namespace.ts index 3595759544c..ff8108c99b5 100644 --- a/js/net/src/ietf/publish_namespace.ts +++ b/js/net/src/ietf/publish_namespace.ts @@ -38,7 +38,8 @@ export interface AdvertParams { /** Write an advertisement's extension parameters into a fresh block. */ export function advertIntoParams(advert: AdvertParams): Parameters { - const params = advert.cluster ? Cluster.intoParams(advert.cluster) : new Parameters(); + const params = new Parameters(); + if (advert.cluster) Cluster.intoParams(advert.cluster, params); params.epoch = advert.epoch; return params; } @@ -184,7 +185,8 @@ export class PublishNamespaceUpdate { if (version === Version.DRAFT_17) { await w.u62(0n); // required_request_id_delta (draft-17 only, removed in draft-18 per #1615) } - const params = Cluster.updateIntoParams(this.update); + const params = new Parameters(); + Cluster.updateIntoParams(this.update, params); if (this.token) tokenIntoRequest(params, this.token, version); await params.encode(w, version); } diff --git a/js/net/src/ietf/request.ts b/js/net/src/ietf/request.ts index b60eebcec06..30f4e5f070b 100644 --- a/js/net/src/ietf/request.ts +++ b/js/net/src/ietf/request.ts @@ -4,25 +4,6 @@ import { Parameters } from "./parameters.ts"; import * as Properties from "./properties.ts"; import { type IetfVersion, Version } from "./version.ts"; -/** - * Requests a draft-14 to -16 peer may hold open at once. - * - * Sized like moq-net's window: twice its default 100,000 announce and 10,000 - * subscription and FETCH caps. Draft-17 dropped MAX_REQUEST_ID. Grants are batched per - * half window, so only about half of it is guaranteed to a peer holding requests open. - */ -export const REQUEST_WINDOW = 240_000n; - -/** - * The SETUP MAX_REQUEST_ID that first admits `window` requests from the peer. - * - * It is exclusive (the draft's "maximum request ID plus 1"), and the peer uses - * only its own parity: even IDs are the client's, odd the server's. - */ -export function initialMaxRequestId(peerClient: boolean, window: bigint = REQUEST_WINDOW): bigint { - return window * 2n + (peerClient ? 0n : 1n); -} - export class MaxRequestId { static id = 0x15; diff --git a/js/net/src/ietf/setup.ts b/js/net/src/ietf/setup.ts index ca002f06810..b14619aea68 100644 --- a/js/net/src/ietf/setup.ts +++ b/js/net/src/ietf/setup.ts @@ -1,6 +1,6 @@ import type { Reader, Writer } from "../stream.ts"; import * as Message from "./message.ts"; -import { SetupOptions } from "./parameters.ts"; +import { SetupOptions } from "./setup_options.ts"; import { type IetfVersion, Version } from "./version.ts"; // Draft-17 unified SETUP message (0x2F00) diff --git a/js/net/src/ietf/setup_options.ts b/js/net/src/ietf/setup_options.ts new file mode 100644 index 00000000000..f8879de4b82 --- /dev/null +++ b/js/net/src/ietf/setup_options.ts @@ -0,0 +1,219 @@ +import type { Reader, Writer } from "../stream.ts"; +import { AUTHORIZATION_TOKEN } from "./token.ts"; +import { type IetfVersion, Version } from "./version.ts"; + +/// Setup Option key constants (separate namespace from Message Parameters). +export const SetupOption = { + Path: 1n, + MaxRequestId: 2n, + AuthorizationToken: AUTHORIZATION_TOKEN, + MaxAuthTokenCacheSize: 4n, + Authority: 5n, + Implementation: 7n, + /** HOP_ID, from the MoQ Cluster extension. See `cluster.ts`. */ + HopId: 0x40b54n, + /** RELAY_COST, from the MoQ Cluster extension. See `cluster.ts`. */ + RelayCost: 0x40b56n, + /** SOLICIT, from the MoQ Solicit extension. See `solicit.ts`. */ + Solicit: 0x40b5an, + /** HIDDEN, from the MoQ Hidden extension. See `hidden.ts`. */ + Hidden: 0x40b5cn, + /** Subscriber max age, from the MoQ Timestamp extension. */ + MaxAge: 0x915c4n, + /** AUTH, from the MoQ Auth extension. See `auth.ts`. */ + Auth: 0x40b60n, + /** ACTIVE_COUNT, from the MoQ Active Count extension. See `active_count.ts`. */ + ActiveCount: 0x40b64n, + /** EPOCH, from the MoQ Epoch extension. See `epoch.ts`. */ + Epoch: 0x40b68n, +} as const; + +// Unknown SETUP options may repeat, including GREASE (draft-21 section 9.1). +const KNOWN_SETUP_OPTIONS: readonly bigint[] = Object.values(SetupOption); + +/** + * Requests a draft-14 to -16 peer may hold open at once. + * + * Sized like moq-net's window: twice its default 100,000 announce and 10,000 + * subscription and FETCH caps. Draft-17 dropped MAX_REQUEST_ID. Grants are batched per + * half window, so only about half of it is guaranteed to a peer holding requests open. + */ +export const REQUEST_WINDOW = 240_000n; + +/** + * The SETUP MAX_REQUEST_ID that first admits `window` requests from the peer. + * + * It is exclusive (the draft's "maximum request ID plus 1"), and the peer uses + * only its own parity: even IDs are the client's, odd the server's. + */ +export function initialMaxRequestId(peerClient: boolean, window: bigint = REQUEST_WINDOW): bigint { + return window * 2n + (peerClient ? 0n : 1n); +} + +/// Setup Options, used in SETUP messages. +/// +/// In d14-d16 these are count-prefixed ("Setup Parameters"). +/// In d17 these have no count prefix ("Setup Options") and read/write to end of message. +export class SetupOptions { + vars: Map; + bytes: Map; + + constructor() { + this.vars = new Map(); + this.bytes = new Map(); + } + + get size() { + return this.vars.size + this.bytes.size; + } + + setBytes(id: bigint, value: Uint8Array) { + if (id % 2n !== 1n) { + throw new Error(`invalid parameter id: ${id.toString()}, must be odd`); + } + this.bytes.set(id, value); + } + + setVarint(id: bigint, value: bigint) { + if (id % 2n !== 0n) { + throw new Error(`invalid parameter id: ${id.toString()}, must be even`); + } + this.vars.set(id, value); + } + + getBytes(id: bigint): Uint8Array | undefined { + if (id % 2n !== 1n) { + throw new Error(`invalid parameter id: ${id.toString()}, must be odd`); + } + return this.bytes.get(id); + } + + getVarint(id: bigint): bigint | undefined { + if (id % 2n !== 0n) { + throw new Error(`invalid parameter id: ${id.toString()}, must be even`); + } + return this.vars.get(id); + } + + removeBytes(id: bigint): boolean { + if (id % 2n !== 1n) { + throw new Error(`invalid parameter id: ${id.toString()}, must be odd`); + } + return this.bytes.delete(id); + } + + removeVarint(id: bigint): boolean { + if (id % 2n !== 0n) { + throw new Error(`invalid parameter id: ${id.toString()}, must be even`); + } + return this.vars.delete(id); + } + + async encode(w: Writer, version: IetfVersion) { + if (version !== Version.DRAFT_14 && version !== Version.DRAFT_15) { + // d17+: no count prefix; d16: count prefix + if (version === Version.DRAFT_16) { + await w.u53(this.vars.size + this.bytes.size); + } + + // Delta encoding: collect all keys, sort, encode deltas + const all: { key: bigint; isVar: boolean }[] = []; + for (const id of this.vars.keys()) all.push({ key: id, isVar: true }); + for (const id of this.bytes.keys()) all.push({ key: id, isVar: false }); + all.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0)); + + let prevId = 0n; + for (let i = 0; i < all.length; i++) { + const { key, isVar } = all[i]; + const delta = i === 0 ? key : key - prevId; + prevId = key; + await w.u62(delta); + + if (isVar) { + // biome-ignore lint/style/noNonNullAssertion: key is guaranteed to exist in vars map + await w.u62(this.vars.get(key)!); + } else { + // biome-ignore lint/style/noNonNullAssertion: key is guaranteed to exist in bytes map + const value = this.bytes.get(key)!; + await w.u53(value.length); + await w.write(value); + } + } + } else { + await w.u53(this.vars.size + this.bytes.size); + + for (const [id, value] of this.vars) { + await w.u62(id); + await w.u62(value); + } + + for (const [id, value] of this.bytes) { + await w.u62(id); + await w.u53(value.length); + await w.write(value); + } + } + } + + static async decode(r: Reader, version: IetfVersion): Promise { + const params = new SetupOptions(); + + if (version !== Version.DRAFT_14 && version !== Version.DRAFT_15 && version !== Version.DRAFT_16) { + // d17+: no count prefix, read until reader is done + let prevType = 0n; + let i = 0; + while (!(await r.done())) { + const delta = await r.u62(); + const id = i === 0 ? delta : prevType + delta; + prevType = id; + i++; + + if (id % 2n === 0n) { + if (KNOWN_SETUP_OPTIONS.includes(id) && params.vars.has(id)) { + throw new Error(`duplicate parameter id: ${id.toString()}`); + } + const varint = await r.u62(); + params.setVarint(id, varint); + } else { + if (KNOWN_SETUP_OPTIONS.includes(id) && params.bytes.has(id)) { + throw new Error(`duplicate parameter id: ${id.toString()}`); + } + const size = await r.u53(); + const bytes = await r.read(size); + params.setBytes(id, bytes); + } + } + } else { + const count = await r.u53(); + let prevType = 0n; + + for (let i = 0; i < count; i++) { + let id: bigint; + if (version === Version.DRAFT_16) { + const delta = await r.u62(); + id = i === 0 ? delta : prevType + delta; + prevType = id; + } else { + id = await r.u62(); + } + + if (id % 2n === 0n) { + if (KNOWN_SETUP_OPTIONS.includes(id) && params.vars.has(id)) { + throw new Error(`duplicate parameter id: ${id.toString()}`); + } + const varint = await r.u62(); + params.setVarint(id, varint); + } else { + if (KNOWN_SETUP_OPTIONS.includes(id) && params.bytes.has(id)) { + throw new Error(`duplicate parameter id: ${id.toString()}`); + } + const size = await r.u53(); + const bytes = await r.read(size); + params.setBytes(id, bytes); + } + } + } + + return params; + } +} diff --git a/js/net/src/ietf/solicit.test.ts b/js/net/src/ietf/solicit.test.ts index c7937498b3b..af5f4562eaf 100644 --- a/js/net/src/ietf/solicit.test.ts +++ b/js/net/src/ietf/solicit.test.ts @@ -1,5 +1,5 @@ import { expect, test } from "bun:test"; -import { SetupOption, SetupOptions } from "./parameters.ts"; +import { SetupOption, SetupOptions } from "./setup_options.ts"; import { solicitFromSetup, solicitIntoSetup } from "./solicit.ts"; /** diff --git a/js/net/src/ietf/solicit.ts b/js/net/src/ietf/solicit.ts index 9ee96c3494b..c7f3d135317 100644 --- a/js/net/src/ietf/solicit.ts +++ b/js/net/src/ietf/solicit.ts @@ -1,4 +1,4 @@ -import { SetupOption, type SetupOptions } from "./parameters.ts"; +import { SetupOption, type SetupOptions } from "./setup_options.ts"; /** * The MoQ Solicit extension (draft-lcurley-moq-solicit-00). diff --git a/js/net/src/ietf/token.test.ts b/js/net/src/ietf/token.test.ts index 8b05ebb909f..99c96d4b363 100644 --- a/js/net/src/ietf/token.test.ts +++ b/js/net/src/ietf/token.test.ts @@ -2,7 +2,8 @@ import { expect, test } from "bun:test"; import { ProtocolViolation, SessionCode } from "../error.ts"; import { Reader, Writer } from "../stream.ts"; import * as Varint from "../varint.ts"; -import { Parameters, SetupOption, SetupOptions } from "./parameters.ts"; +import { Parameters } from "./parameters.ts"; +import { SetupOption, SetupOptions } from "./setup_options.ts"; import { AUTHORIZATION_TOKEN, TOKEN_OUT_OF_BAND, diff --git a/js/net/src/ietf/token.ts b/js/net/src/ietf/token.ts index 726cd756990..4e3d8be23d2 100644 --- a/js/net/src/ietf/token.ts +++ b/js/net/src/ietf/token.ts @@ -1,6 +1,7 @@ import { ProtocolViolation, SessionCode } from "../error.ts"; import * as Varint from "../varint.ts"; -import type { Parameters, SetupOptions } from "./parameters.ts"; +import type { Parameters } from "./parameters.ts"; +import type { SetupOptions } from "./setup_options.ts"; import { type IetfVersion, Version } from "./version.ts"; /** From 6913dc5ee013626115d7605fa37569874bc026b4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 21 Oct 2026 00:31:54 -0700 Subject: [PATCH 3/3] quest(m1): checkpoint the artifact size audit Re-measures native, WASM and JS sizes against the m0 baseline commit, records the transport erasure ceiling for net-erase-transport, carries the pako lead into the js/net compressed tracks quest, and blocks the run's finish on net-erase-transport so the audit before the breaking cut sees its result. Co-Authored-By: Claude Opus 5.5 --- quest/m1/audit-size.md | 140 ++++++++++++++++++++++++---------------- quest/m1/compress/js.md | 6 ++ 2 files changed, 89 insertions(+), 57 deletions(-) diff --git a/quest/m1/audit-size.md b/quest/m1/audit-size.md index 0d4c7f3c43a..9e13fa78d66 100644 --- a/quest/m1/audit-size.md +++ b/quest/m1/audit-size.md @@ -19,64 +19,90 @@ Only a change that needs a maintainer decision (public API, scope) or is independently landable and too large to review alongside the rest becomes a follow-up through `/quest-plan`. +Checkpointed 2026-10-21, a day after the m0 run, with nothing to plan but +the quests below. The run finishes after +[moq-net compiles once](/quest/m1/net-erase-transport.md) lands, so the audit +before the breaking cut sees its result and the rest of m1. + What to check first: whether the nightly `sizes` job (`sh/size/`) has run. -It needs the Linux release builds, skipped since the 2026-10-11 nixpkgs -bump broke their link. If it has, its history replaces the local method below. -Then whether [moq-net compiles once](/quest/m1/net-erase-transport.md) and -[the catalog publish path compiles once](/quest/m2/catalog-publish-once.md) -landed, and re-attribute the native rows if so. - -### Baselines (m0 run, 2026-10-19 and 2026-10-20) - -Release assets are x86_64 Linux, stripped as shipped. main is a local build -with the host linker, not `cargo zigbuild`, so compare main to main. JS rows -are `sh/size/bundles.ts` first-load gzip; main is the workspace build. - -| Artifact | Earlier release | Release (2026-10-17) | main (2026-10-20) | -|---|---|---|---| -| `moq-relay` | 30.69 MiB (0.14.5) | 37.70 MiB (0.17.7) | 31.29 MiB | -| `moq` CLI | 36.38 MiB (0.8.2) | 49.70 MiB (0.14.7) | 48.14 MiB | -| `libmoq_ffi.so` | 16.80 MiB (0.3.16) | 25.22 MiB (0.4.17) | 31.86 MiB | -| `libmoq` tarball | 10.49 MiB (0.5.15) | 14.29 MiB (0.6.17) | not built | -| `moq_bg.wasm` gzip | ~471 KB (06-09) | not published | 771 KB | -| `net` | 65.3 KB (09-09) | 93.0 KB | 100.9 KB | -| `watch` | 120.3 KB | 160.5 KB | 161.3 KB | -| `watch-ui` | 131.8 KB | 172.6 KB | 173.8 KB | -| `publish` | 94.9 KB | 230.6 KB | 151.2 KB | - -Native and WASM main numbers are from 2026-10-19 (2b28f5eac); JS from -2026-10-20, after the fix below. - -### Results of the m0 run - -- Fixed: `@moq/net` loads the IETF session code on demand, since lite is - preferred. First load fell 126.8 to 100.9 KB (net), 187.3 to 161.3 KB - (watch), 199.8 to 173.8 KB (watch-ui) and 176.8 to 151.2 KB (publish). - `js/net/src/ietf/index.test.ts` fails if the entry statically reaches it - again. -- Planned: [moq-net compiles once](/quest/m1/net-erase-transport.md), most of - the native growth since July (the drivers are monomorphized per transport and - per instantiating crate), and - [the catalog publish path compiles once](/quest/m2/catalog-publish-once.md), - about 1 MiB of the CLI. -- Explained, no action: `moq-quic` replacing quinn, `kio`, `unsafe-libopus`, - `moq-video`/`moq-vaapi` in the FFI library and `fast_image_resize` in - `libmoq`. The CLI embeds the relay (+5.4 MiB since 0.12.0) and defaults to - WebRTC (about 1.2 MiB) and the `s3`, `gcs` and `azure` stores; main drops - the `iroh` default from both. The FFI library keeps its symbol table on - purpose for UniFFI (about 3.5 MiB). WASM growth is `moq-net`'s. -- `@moq/publish` 0.5.x bundles `mediabunny` eagerly; main fixed it in - [moq-dev/moq#5267](https://github.com/moq-dev/moq/pull/5267), not yet - released when measured. - -Candidates for next run: the eager IETF SETUP code in `@moq/net` is still -29.9 KiB raw, mostly `parameters.ts`, whose SETUP options share a module with -the request parameters (and `filter.ts`); splitting them needs `cluster.ts`, -`token.ts` and `request.ts` reshuffled, for about 4 KB gzip. - -Method: `nm` symbol attribution by crate path and by instantiating crate on -unstripped release `.so`/`.a` files and local `profiling` builds, and esbuild -metafiles from `sh/size/bundles.ts` for JS. +It needs the Linux release builds, which still fail to link +([moq-dev/moq#6090](https://github.com/moq-dev/moq/pull/6090) was open on +2026-10-21). If it has, its history replaces the local method below. Then +re-attribute the native rows for the erasure quest, and measure `@moq/net` +once [compressed tracks in js/net](/quest/m1/compress/js.md) moves `pako` in. + +### Baselines + +Release assets are x86_64 Linux, stripped as shipped. main is a local +`cargo build --release` (rust-lld, not `cargo zigbuild`), so compare main to +main. WASM is `just js wasm` output, `gzip -9`. JS rows are +`sh/size/bundles.ts` first-load gzip on the workspace build. + +| Artifact | Release (2026-10-17) | main 2b28f5eac (10-19) | main 7d2a91fe66 (10-20) | checkpoint | +|---|---|---|---|---| +| `moq-relay` | 37.70 MiB (0.17.7) | 31.31 MiB | 31.81 MiB | same | +| `moq` CLI | 49.70 MiB (0.14.7) | 47.54 MiB | 48.45 MiB | same | +| `libmoq_ffi.so` | 25.22 MiB (0.4.17) | 34.16 MiB | 34.80 MiB | same | +| `libmoq` tarball | 14.29 MiB (0.6.17) | not built | not built | not built | +| `moq_bg.wasm` gzip | not published | 771.0 KB | 861.9 KB | same | +| `net` | 93.0 KB | 100.9 KB | 101.2 KB | 95.7 KB | +| `watch` | 160.5 KB | 161.3 KB | 161.8 KB | 156.7 KB | +| `watch-ui` | 172.6 KB | 173.8 KB | 174.3 KB | 169.2 KB | +| `publish` | 230.6 KB | 151.2 KB | 151.7 KB | 146.5 KB | + +Earlier releases: relay 30.69 MiB (0.14.5), CLI 36.38 MiB (0.8.2), FFI +16.80 MiB (0.3.16), `libmoq` 10.49 MiB (0.5.15), WASM ~471 KB (06-09), +`net` 65.3 KB, `watch` 120.3 KB, `watch-ui` 131.8 KB and `publish` 94.9 KB +(09-09). The 2b28f5eac column was rebuilt here from the same commit; the m0 +run's FFI (31.86 MiB) and CLI (48.14 MiB) figures for it do not reproduce. + +### Results so far + +- Fixed (m0): `@moq/net` loads the IETF session code on demand. + `js/net/src/ietf/index.test.ts` fails if the entry statically reaches it. +- Fixed (checkpoint): SETUP options live in `ietf/setup_options.ts`, apart + from the message parameter codec (`parameters.ts`, `filter.ts`), so a lite + session never loads them. First load fell 5.1 to 5.5 KB gzip in every + bundle; the same test fails if SETUP reaches `parameters.ts` again. +- Planned: [moq-net compiles once](/quest/m1/net-erase-transport.md). On + 7d2a91fe66, `moq-net` is 9.5 MiB of the relay's text and 7.7 MiB of the FFI + library's; one copy of each function would be about 2.5 MiB in both, so the + ceiling is about 7.0 and 5.2 MiB. In the relay, the binary crate (a 16-line + `main.rs`) instantiates 3.1 MiB of it, `moq-tokio` 3.2 MiB and the library + 1.9 MiB; identical instantiations repeated across crates are 5.0 MiB. They + are not byte-identical after LTO: `-Wl,--icf=all` saves only 0.23 MiB. +- Planned: [the catalog publish path compiles once](/quest/m2/catalog-publish-once.md) + (`moq-json`'s diff serializer, +0.14 MiB of the CLI this run). +- Explained, no action: native growth since 2b28f5eac is `moq-net` features + (ranges and time anchors, TRACKS, followed instances, compressed tracks): + +0.41 to 0.53 MiB of text per binary. The CLI adds import stats (+0.08 MiB) + and `moq-mux` (+0.06 MiB); `usage-rs` 7 saves 0.07 MiB. WASM code grew + 187 KB raw: `zlib-rs` 55 KB (compressed tracks; `miniz_oxide` is refused for + its sync flush bug), `moq-net` 88 KB, `hashbrown`/`hashlink`/`foldhash` + 23 KB. JS grew 0.3 to 0.5 KB gzip. +- Explained in m0, unchanged: `moq-quic` replacing quinn, `kio`, + `unsafe-libopus`, `moq-video`/`moq-vaapi` in the FFI library, + `fast_image_resize` in `libmoq`, the relay and WebRTC embedded in the CLI, + the object-store defaults, and the FFI symbol table kept for UniFFI. + +Leads: + +- `pako` costs `watch` and `publish` 12.8 KB gzip through `@moq/json`. A player + only inflates: `Inflate` alone is 9.9 KB, and the browser's + `DecompressionStream("deflate-raw")` would be free if it yields each + sync-flushed frame. Carried into [compressed tracks in js/net](/quest/m1/compress/js.md). +- `zod/mini` is 9 KB raw of `@moq/net`'s first load for one branded bigint + (`HopSchema`), and `@moq/hang` imports it as both `zod/mini` and + `@zod/mini`. Not worth a quest alone. + +Method: `nm` symbol attribution by crate path and by instantiating crate (the +v0 mangling suffix) on local `profiling` builds of both revisions, the wasm +name section from a `wasm-release` build with `CARGO_PROFILE_WASM_RELEASE_STRIP=none`, +and esbuild metafiles from `sh/size/bundles.ts` for JS. + +## Required + +- [moq-net compiles once](/quest/m1/net-erase-transport.md) - re-measure the native rows once the drivers compile once ## Related diff --git a/quest/m1/compress/js.md b/quest/m1/compress/js.md index f78f9ff5319..02c70259d99 100644 --- a/quest/m1/compress/js.md +++ b/quest/m1/compress/js.md @@ -16,6 +16,12 @@ See the [epic](/quest/m1/compress/README.md) for the decisions. - Mirror the Rust model: store compressed slices, one inflated copy per group shared by plain readers, the declared size enforced while inflating. - Docs inline beside the Rust ones in `doc/concept`. +- Size: `pako` is 12.8 KB gzip of the `watch` and `publish` bundles today, + and moving it into js/net puts it in every first load. A player only + inflates: keep deflate out of a consumer's static graph (`Inflate` alone is + 9.9 KB), or use `DecompressionStream("deflate-raw")` if it yields each + sync-flushed frame. Measure with `sh/size/bundles.ts` + ([size audit](/quest/m1/audit-size.md)). Tests: Rust and JS publish compressed tracks to each other over lite-07 through moq-relay; a JS publisher on lite-06 sends plain frames.