Skip to content

diffr web: size the worker pool per browser and release the engine when idle - #1093

Open
milanb17 wants to merge 2 commits into
claude/project-thread-hwb7l0from
claude/diffr-web-mobile-perf
Open

milanb17 wants to merge 2 commits into
claude/project-thread-hwb7l0from
claude/diffr-web-mobile-perf

Conversation

@milanb17

Copy link
Copy Markdown
Contributor

Summary

Size diffr web's worker pool for the browser it runs in, and let the compiled engine go when the pool is idle. Stacks on #1022; merge #1022 first.

iOS Safari        → 1 worker, replaced past 256 MB
Android Chrome    → 2 workers with 8 GB or more, else 1; 384 MB
Desktop, < 8 GB   → up to 2 workers; 512 MB
Desktop           → cores − 1, at most 8; 1 GB
  • iOS kills a tab over its memory budget, often well under 1 GB, instead of failing the allocation, and reports neither memory nor cores. Before this, a phone got the desktop pool: several workers, each allowed 1 GB of wasm memory that never shrinks.
  • When the last idle worker goes, the page drops its compiled module too. Compiling again takes 50–110 ms, so the next file barely notices, and the memory can be reclaimed.

Evidence

  • iPhone 17 Pro simulator, vite v5.3.0...v5.4.0 (217 files), cold loads, Safari's process footprint sampled every 2 s.
  • With the release instrumented: it fires about 13 s after load with no workers left. A cold compile took 48–107 ms; three in-page recompiles took 51–60 ms each.
  • Memory during an idle 3-minute session is the same with and without the release (within ~50 MB run-to-run noise): Safari doesn't collect the dropped module while the page is idle. It gave back 56 MB as soon as the next compile allocated.
  • Browser typecheck and lint pass. No tests cover the pool.

Merge Danger

Door: two-way; revert the commits.

Blast Radius: diffr web's worker pool. Phones and small desktops diff large comparisons with fewer workers, so slower but within memory. Every device recompiles the engine (~0.1 s) for the first file after 3 idle seconds.

Agent-Session: 5eb4067a-b2f6-4508-a6dd-0471ff2c14d1
Agent-Session: 429958d8-68f3-4f68-bd3b-a8371e7feb8e
The page kept the compiled module after its pool went idle so the next
file's worker could start without a compile. On iOS that module held
about 170 MB, while compiling again takes 50-110 ms in the simulator. The
module now goes with the last worker.

Agent-Session: 429958d8-68f3-4f68-bd3b-a8371e7feb8e
Agent-Session: 5eb4067a-b2f6-4508-a6dd-0471ff2c14d1
@milanb17
milanb17 marked this pull request as ready for review October 12, 2026 16:45
ketan0 added a commit that referenced this pull request Oct 23, 2026
Branch and PR inputs now resolve to the same branch and PR without
changing the agent-facing API or replacing an explicitly chosen
comparison. PR retargeting uses the same resolver as PR creation, and a
named branch discovers its matching open GitHub PR. A branch board whose
PR is published later shows that PR when read and is reused when the PR
is later opened by number.

What is learned is stored on the review's existing `origin` record. The
one new field is optional, so older stores and shared bundles parse
unchanged and no migration is needed: `pullRequestBaseBranch`, the
branch the PR merges into, which can differ from the chosen comparison
base.

Stack discovery uses GitHub's native stack first. Otherwise it walks
open same-repository PRs by base and head branch in both directions,
stopping at forks, cycles and ambiguous continuations, and lists PRs
that have no whiteboard. A short-lived (60 s) cache shares one read of
the repository's open PRs between PR discovery and stack walking.
Optional forge reads run outside the save queue and fall back to local
context when unavailable.

Known limits: PR discovery does not cover fork PRs or local branches
renamed away from the PR's head branch. A PR found by discovery is shown
but not saved on the board.

Review fixes preserve writes accepted before shutdown and reject new
writes once closing starts. Branch-board reuse checks repository
identity, while preserving reuse across worktrees and same-origin
clones. The stack menu labels local branches “from branch bases” instead
of “from GitHub”.

Validation: root format and lint, backend/protocol/canvas typechecks,
the full backend suite (1,305 passed, 1 skipped), six selector browser
tests, and a desktop build. The corrected menu was checked in the
isolated Desktop in dark and light themes, including Escape and focus
restoration. In an isolated Desktop against live GitHub, #1094 (no
GitHub stack) shows the inferred chain #1018 → #1022 → #1093 → #1094 →
#1095 → #1097, and #1355 shows its native GitHub stack #1353–#1356.

Whiteboard review: `b4a369de-c96f-49d5-a334-66aedeaac5d4`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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