Skip to content

fix(flate): stop inflation at the group budget - #6900

Merged
kixelated merged 4 commits into
mainfrom
quest/m1/cut-audit/flate-budget
Oct 27, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m1/cut-audit/flate-budget

Conversation

@kixelated

@kixelated kixelated commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A compressed frame could inflate completely after crossing the 32 MiB group budget. Tiny decoded frames also retained pako's 64 KiB scratch buffers. The shared decoder is consumed by compressed snapshots/streams, including hangz and hang timelines.

Approach

Throw inside pako's output callback on the first over-budget chunk, preserve the cumulative window budget, and copy returned frames into tight owned buffers. Release captured chunks after every push, including failures. Empty slices return tightly owned empty buffers and an overflowed decoder stays failed. Add deterministic output-count, exact-budget, and retained-buffer boundary tests, plus just js flate-decoder-bench over the real stream consumer, registered in Nightly.

Impact

  • Public API: unchanged. Wire: unchanged. No package version bump.
  • Oversized slices stop at the group budget plus one pako scratch chunk; accepted payloads and compression remain unchanged.
  • Chromium 156 real Stream.Consumer proof: 1,024 one-byte frames retained 67,108,864 bytes before versus 1,024 afterward. The 40 MiB rejected-slice median was 56.7 ms before versus 46.7 ms afterward on this host. Timings are informational; correctness tests assert output and storage bounds without timing thresholds.

Alternatives

Reuse the existing net decoder's throw-inside-onData and tight-copy approach. Discarding excess output still pays for inflation; returning a single chunk's view keeps its larger allocation alive. The existing public codec, budget, and pako chunk size stay in place.

Validation

  • Before the fix, real-pako tests produced all 41,943,040 bytes for the hostile slice and retained 65,536 bytes for a one-byte result.

  • Afterward, all 11 codec tests passed. Actual Chromium benchmark exercised the same compressed stream consumer and checked every frame and over-budget error.

  • just fix, benchmark TypeScript check, and clean committed-head just ci passed at fbae5440066abcb31ad89daea51fe3f1d24221ab, including API Extractor and all 46 flate tests plus affected dependents and tooling. Trusted external quest check --base origin/main --branch quest/m1/cut-audit/flate-budget passed (624 documents). Final Chromium consumer sweep and empty-view ownership proof passed; the Nightly CSV parsed into 14 valid metrics.

  • Current-head review: Codex thumbs-up, independent review and CodeRabbit report no actionable findings.

Follow-ups

No unresolved decisions. Consider a release backport if @moq/flate remains in the shipped cut; this PR does not publish or change a pin.

(Written by GPT-6)

kixelated and others added 3 commits October 26, 2026 18:03
Co-Authored-By: GPT-6 <noreply@openai.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
@kixelated kixelated changed the title @moq/flate stops inflating at its budget fix(flate): stop inflation at the group budget Oct 27, 2026
@kixelated
kixelated marked this pull request as ready for review October 27, 2026 01:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T04:52:20.524083Z 2536cdd New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed fbae5440066abcb31ad89daea51fe3f1d24221ab. No actionable bugs found in the changed code.

Direction is sound: aborting inside onData, preserving the cumulative budget, and returning tight owned buffers address the CPU and retention problems at their source. Reusing the net decoder's approach without coupling the two codecs is appropriately simple; the boundary tests and real-consumer benchmark justify the added coverage. Public API and wire format remain unchanged.

Verification: GitHub source/diff review, including stream/snapshot consumers and the existing net decoder. I did not run tests or independently reproduce the reported browser measurements.

(Written by review (OpenAI))

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
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: c6666028-f956-4602-97b5-8c05020ddba0
Commits

Reviewing files that changed from the base of the PR and between b8561a3 and fbae544.

Files selected for processing: 8
  • js/flate/bench/decoder.ts
  • js/flate/bench/tsconfig.json
  • js/flate/src/codec.test.ts
  • js/flate/src/codec.ts
  • js/justfile
  • quest/m1/cut-audit/README.md
  • quest/m1/cut-audit/flate-budget.md
  • sh/gh/nightly.sh
Files with no reviewable changes: 2
  • quest/m1/cut-audit/README.md
  • quest/m1/cut-audit/flate-budget.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

The decoder now stops inflation when cumulative output exceeds the group cache budget. It copies decoded chunks into owned buffers and clears chunk references after frame processing. Tests cover exact-budget output, bounded excess output, and retained frame buffers. The change also adds decoder benchmarks and wires them into the JavaScript nightly benchmark sequence.

Priority: Normal

Merge Risk: Minimal · up to fbae5

No actionable merge-blocking issue is identified; the change is mergeable after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title "fix(flate): stop inflation at the group budget" matches the main change. The PR stops pako inflation when cumulative decoded output crosses Group.MAX_GROUP_CACHE_BYTES (the 32 MiB group bud…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description directly explains the decoder budget enforcement, tight buffer ownership, tests, benchmarks, and validation described in the changeset.
Full details: Title check

Explanation

The title "fix(flate): stop inflation at the group budget" matches the main change. The PR stops pako inflation when cumulative decoded output crosses Group.MAX_GROUP_CACHE_BYTES (the 32 MiB group budget). The title is short, specific, and follows a conventional-commit style. It does not cover the tight-buffer copying or the benchmark, which is acceptable.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 4 files. (2 skipped: 2 unsupported.)

Finishing Touches
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary: landing head fbae544 unchanged. Codex 👍 and CodeRabbit (no findings) cover this head; no unresolved threads. Locally re-ran just check (js check/test including all 46 @moq/flate tests, gh, shell, quest, markdown lanes) and a trusted quest check --base origin/main (624 documents ok). No conflicts with main; no decisions outstanding.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 27, 2026
Resolve the cut-audit README conflict as the union of removals: this
branch finishes flate-budget and main (#6896) finished watch-source-robust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Re-landing after the merge_conflict dequeue that followed moq-dev/moq#6896.

  • Merged origin/main into the branch (2536cdd). The only conflict was quest/m1/cut-audit/README.md: this PR removes the flate-budget entry and fix(watch): keep supported renditions available #6896 removed watch-source-robust, so the resolution drops both. No code changes.
  • Trusted quest check --base origin/main --branch quest/m1/cut-audit/flate-budget passed (613 documents); just check passed with every selected module (js, markdown, gh, quest, shell, large_files, toml, nix, justfile).
  • Codex thumbs-up on the new head.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit 4365ee9 Oct 27, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/cut-audit/flate-budget branch October 27, 2026 05:04
kixelated added a commit that referenced this pull request Oct 27, 2026
#6900's new bench ends them with the pre-split close().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant