Skip to content

The JavaScript byte pool carries only what a JS caller can reach - #8821

Merged
kixelated merged 2 commits into
mainfrom
quest/m1/js-pool-reach
Nov 15, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest/m1/js-pool-reach

Conversation

@kixelated

@kixelated kixelated commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/js-pool-reach.md.

Problem

js/net's per-broadcast cache pool ported Rust's byte budget, but every JS pool is built without a capacity and resize had no non-test caller. So Pool.accrue always returned undefined: byte debt, #payDebt, group debt shedding, reader-record debt (and its TooFarBehind end), drop/arrival/reader run billing, and the tail's debt folds ran only in tests, while later PRs kept building on them. The maintainer picked deletion on moq-dev/moq#8764.

Approach

  • cache.ts keeps only the idle window: Pool (expiry, tick clock, sweep), Track (scan order, bounded write-driven scan, full sweep, drop-run expiry hook), and Charge, now just a group's last-access tick. Dropped: capacity, used, resize, accrue, the access mean and sub-tick boosts, debt and its payment, Reader, and the *_OVERHEAD constants.
  • group.ts: deleted #shed, shedGroup, shedReader, and the byte billing. The 32 MiB per-group frame tail cap (#trim) is unchanged.
  • track.ts: deleted debt charging, drop/arrival billing, #shedDrops/#shedArrivals, the folded wake signal, the reader record's floor (#folded, #fold, #settleRecord, #lagged), and the Evicted eviction reason, which only debt produced. Drop-run expiry (#dropsBorn, #expireDrops, #forgot, #rearmDrops) stays, and now registers with the sweep through Track.dropsChanged().
  • tail.ts: deleted the bill, fold(), overtaken(), and the debt folding of #finished/#dropped. lite/subscriber.ts no longer subtracts the overtaken runs, and lite/publisher.ts loses the two record.folded branches, which never fired without a fold.
  • ledger.ts: deleted RUN_OVERHEAD, foldOldest, and size. resume.ts and internal.ts lose the billing hooks.
  • Also fixed a stray doc comment for reaches that sat on the Born interface.
  • Tests: deleted the capacity, debt, billing, and fold tests. The expiry tests stay, minus their pool.used assertions. Three tests had used resize to force eviction and now use the idle window or the tail cap instead: the drop-record widening pair gives the publisher a 10 s expiry, the broadcast fetch test ages the failed group out, and the two shed variants of the takeover test overflow the tail cap.

Choices made without the maintainer (AFK), all reversible in review:

  • I kept the name Charge (and hooks.chargeGroup) for the access record, to keep the diff and the Rust naming parallel, though it no longer bills. Renaming it to something like Access would be fine too.
  • I dropped the sub-tick read/write boosts. They only broke ties for the eviction mean, and expiry already compared whole ticks.
  • Removing the reader floor also removes the lite publisher's Evicted drop for a run the pool folded. No path could reach it.

Impact

  • Public API: none. cache.ts and the removed hooks are package-internal.
  • Wire: none. A JS publisher never sent the Evicted drops this removes, since a fold never happened.
  • Behavior: none on any production path. A JS consumer can't set a pool capacity, and still couldn't before this PR. Rust is unchanged and keeps its capacity: the relay sets one.

Validation

  • bun test in js/net: 3313 pass, 0 fail. Also js/hang 563, js/watch 648, js/publish 379, js/json 191, all passing. just check passes.
  • I checked that the rewritten widening tests really depend on the publisher's expiry: without PUBLISHER_EXPIRY both fail.
  • Bundle (bun build src/index.ts --minify --target browser): 704,080 → 695,084 bytes minified (-9.0 KB), 211,253 → 208,374 gzip -9 (-2.9 KB).
  • Diff: 149 insertions, 1731 deletions.
  • I didn't run it in a browser. Nothing changes on a path a page reaches.

Alternatives

Rejected on #8764: (b) expose capacity to JS callers, (c) keep the code for parity with Rust. Restore it from git once a consumer needs it.

Follow-ups

None.

Models

Size: S
Implementer: Claude, claude-opus-5-5, unknown effort (arm A)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: 80d763f

  • Base: origin/main at fabfe5e

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.1-sol, medium effort

  • Session: 01a1df3e-0f4e-7720-9849-9c6ebc3bb193, round 1

  • Score: 9/10, Source review found no actionable regressions in the focused removal of unreachable byte-budget machinery, with idle expiry and frame-tail limits retained; builds and tests were not run as instructed.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 15, 2026 04:26
Quest-Claim: e809c6a5fecd18bf
No JS caller sets a pool capacity, so byte debt, debt shedding, reader
debt, run billing, and the tail's debt folds never ran outside tests.
Delete them, keeping idle expiry, drop-run expiry, and the per-group
frame tail cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 15, 2026 12:46
@coderabbitai

coderabbitai Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3fd3e0ce-cfb6-4456-af53-8776cf4b1563
Commits

Reviewing files that changed from the base of the PR and between fabfe5e and 80d763f.

Files selected for processing: 19

  • js/net/src/broadcast.test.ts
  • js/net/src/broadcast.ts
  • js/net/src/cache.test.ts
  • js/net/src/cache.ts
  • js/net/src/group.test.ts
  • js/net/src/group.ts
  • js/net/src/internal.ts
  • js/net/src/ledger.test.ts
  • js/net/src/ledger.ts
  • js/net/src/lite/drop_record.test.ts
  • js/net/src/lite/publisher.ts
  • js/net/src/lite/subscriber.test.ts
  • js/net/src/lite/subscriber.ts
  • js/net/src/resume.test.ts
  • js/net/src/resume.ts
  • js/net/src/tail.ts
  • js/net/src/track.test.ts
  • js/net/src/track.ts
  • quest/m1/js-pool-reach.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

I reviewed the full removal of the JS byte budget from js/net's cache pool. I traced each deleted branch back to the condition that made it dead: no JS caller sets capacity or calls resize, so Pool.accrue always returned undefined, Reader.debt was always 0, and the record floor #folded stayed at 0n.

  • cache.ts slimmed to the idle window — Charge now records only the last access as a whole tick. now - accessed > expiry matches the old now - floor(stamp / 4) > expiry, so expiry timing is unchanged.
  • Reader record floor removed (track.ts) — with #folded stuck at 0n, told, untold, #reportRun, and record.folded were already identities or always false. Dropping them changes nothing in either lite publisher branch.
  • Tail fold and overtaken removed (tail.ts, lite/subscriber.ts) — overtaken() always returned [] without a fold, so subscribing recorded directly matches the old owed.
  • Debt hooks removed (group.ts, ledger.ts, resume.ts, internal.ts) — #shed, shedReader, foldOldest, billTrack/billSubscriber, and the folded signal had no production trigger. #trim's 32 MiB tail cap is kept.
  • #evict always ends with TooFarBehind — the "evicted" reason came only from #payDebt, and every other caller already used the default.
  • Tests rewritten to use expiry or the tail cap — the widening pair, the broadcast fetch test, and the takeover shed variants still force the same loss through paths that production code can reach.

I ran the touched suites locally: cache, lite/drop_record, broadcast, and ledger (71 pass), plus track, group, resume, lite/subscriber, and lite/publisher (800 pass). tsc --noEmit -p net/tsconfig.json and Biome are clean on the touched files. A grep at head found no leftovers that are now unused.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 7f19961 Nov 15, 2026
8 checks passed
@kixelated
kixelated deleted the quest/m1/js-pool-reach branch November 15, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant