Repository navigation
fix: keep the Gateway responsive while extracting web pages - #200925
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review Please review the worker extraction and caller-owned abort/timeout boundary at e5a678f. The intentional tradeoff is that admitted worker work finishes after cancellation, while the caller promptly stops awaiting and discards the result. The public extraction request remains unchanged. The PR records the output-equality proof and the separate, pending performance-cost acceptance decision. |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesMoves Readability extraction into the existing worker pool and stops awaiting extraction when the fetch is canceled or times out. Example: Extract a 900 KB HTML article while the Gateway handles other requests.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a current main-thread bottleneck without actionable code findings. The recorded owner acceptance resolves the previous performance decision; exact-head CI remains incomplete. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe web_fetch tool downloads guarded HTTP content, dispatches HTML to plugin-owned extractors, and publishes readable text through its existing fallback and cache owners. flowchart LR
A[web_fetch request] --> B[Guarded HTTP fetch]
B --> C[Extractor bridge]
C --> D[Shared compute worker pool]
D --> E[Readability and rendering]
E --> F[Result publication]
B --> G[Caller and deadline signal]
G --> C
Technical reviewBest possible solution: Retain plugin-owned extraction, the shared SDK worker pool, and caller-owned cancellation with the recorded performance tradeoff. Do we have a high-confidence way to reproduce the issue? Current main visibly performs CPU-heavy parsing and rendering on the calling thread; this read-only review did not execute target code. Is this the best way to solve the issue? The change uses existing transport, admission, sizing, and cancellation owners while preserving the extraction algorithm, making it a focused fix rather than a parallel implementation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ee543dc62721. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +62, Tests +331, Docs +5, Config +5, Generated 0, Other -1. Total +402 across 16 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 17, 2026, 10:15 PM ET / November 18, 2026, 03:15 UTC (Revision 4). |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Addressing the latest review’s open item against
The other initial-run failure is separately proven inherited: the heartbeat-rollup browser test expects “Heartbeat Respond” but renders “Used tools”. The same focused test fails on both this candidate and exact main parent The body now includes the successful full local build and another 600 exact comparisons through the built worker. The original extraction/HTTP/packaging proof has 51 passing tests. The requested owner-level corpus proof is complete; no whole-Gateway surge proof is claimed. Packaged measurements refine the adverse costs to +20–23% total CPU p95 and a 442 ms first-use sample (332 ms main callback). Explicit performance-cost acceptance remains pending. Normal CI is being attached to the final head; neither prior-head CI nor review is being called final-head green. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Lead (owner) decision for #200925, recorded for the PR per the performance skill: ACCEPTED: +20–23% total CPU p95 per extraction, plus a one-time first-use cost of 442 ms (332 ms main callback) per process for the worker/module load, in exchange for main-thread CPU p95 dropping 220–227 ms → 0.42 ms and longest callback p95 208–215 ms → 0.20 ms with byte-equal output. Rationale: on Team the Gateway main thread is the scarce resource (ELU pinned at 1.0 for long stretches today, 16+ cores mostly idle), so moving parse work to a worker at some extra total CPU is the right trade. The first-use cost is once per Gateway process.
The lead classifies the Inbox UI CI failure as a hosted intermittent after passing candidate and parent replays, and authorizes one failed-job-only rerun. A repeated failure will be diagnosed rather than waived as inherited. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…#200925) * perf(web-fetch): offload readability extraction through SDK workers * fix(web-readability): declare the worker build entry
* perf(web-fetch): offload readability extraction through SDK workers * fix(web-readability): declare the worker build entry (cherry picked from commit a2c1b0e) Co-authored-by: RomneyDa <[email protected]>
…#200925) * perf(web-fetch): offload readability extraction through SDK workers * fix(web-readability): declare the worker build entry Release adaptation: Reviewed readability worker and unchanged redirect helper extraction; shrink-only assertion baseline preserved. (cherry picked from commit a2c1b0e) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fetching a large HTML page can stall unrelated Gateway work while Readability parses and renders it. The existing async extractor still performed that CPU work on the Gateway thread.
User Impact
Readability extraction runs in a worker while preserving text, Markdown, titles, and the existing sanitized HTML size/depth limits. Cancellation and the existing HTTP request deadline stop the caller's wait; late extraction results cannot trigger fallback or enter the fetch cache.
Why This Change Was Made
The plugin uses the existing SDK worker transport, compute sizing, shared admission, and pending task/byte limits. The extraction request contract is unchanged. Sanitization, cap checks, DOM parsing, Readability, and rendering move together; there was no redundant DOM parse or defensive clone to delete.
Accepted cancellation tradeoff: extraction already admitted to a worker continues to completion after a rare caller abort or timeout, and its result is discarded. Work retains the existing HTML limits. Core owns the race against the HTTP guard's existing composed signal; the plugin does not receive cancellation or create another timeout.
The production delta is +67 lines: +62 source lines for the offload and lifetime boundary, plus five lines declaring the package-owned worker entry. There are no new dependencies, configuration options, caches, or schemas.
Evidence
Acceptance requires identical output and lower warm main-thread CPU/longest-callback p95. Any total-cost or first-use regression requires explicit owner acceptance.
The synthetic corpus has 20 pages across five article/document shapes and four sizes (50 KB, 250 KB, 900 KB, 2 MB), tested in text and Markdown modes. Five interleaved A1/A2/B rounds yielded 600 exact serialized-output matches in each of the source and packaged runs (1,200 comparisons total); all hashes also match the original checkout. The 2 MB cases preserve the existing null result after sanitization and the size cap.
Node 26.12.1, 32 logical CPUs, 200 warmed samples per phase. Packaged-run host load fell from 32 to 24. Main-thread CPU uses
threadCpuUsage; longest callbacks use async hooks without a spinning probe. Separate V8 sampling passes include collected objects: main allocation per 40 extractions was 2143.06/2131.89/9.81 MiB; total allocation was 2143.06/2131.89/2214.54 MiB. Retained RSS was not measured in isolated processes. This is extractor-owner proof, not a whole-Gateway surge benchmark.The packaged first-use samples were 33 ms inline and 442 ms via the worker, including a 332 ms main callback in B. These are single first-use samples; A2 reused loaded dependencies and is not another cold control. The earlier source run measured 41/2,100 ms, with higher host load. The performance owner explicitly accepted the packaged total-CPU p95 increase of 20–23% and one-time first-use cost on November 17, 2026, in exchange for the measured warm main-thread responsiveness improvement. The measured median CPU increase remains 39–46%. The owner decision is posted verbatim in a PR comment.
Reproduce source:
nice -n 10 node --import ./scripts/tsx.mjs extensions/web-readability/test/web-content-extractor.bench.ts <output.json>. For packaged proof, runpnpm build, copy the identical committed benchmark todist/extensions/web-readability/test/web-content-extractor.bench.ts, and run that file with plain Node and an output JSON path. Remove the copied proof file afterward.Focused proof covers the real worker's extraction output and real guarded HTTP abort/timeout flows, including discarded late results and no fallback/cache publication. The final candidate passed 51 focused tests across the extraction bridge, real HTTP abort/timeout and cache behavior, real worker extraction, and runtime process packaging. Both new cancellation regressions fail on the original bridge.
pnpm check:changedcompleted: every gate passed except the moved assertion allowance and benchmark lint; both were corrected and passed focused reruns. The assertion baseline only shrinks, and benchmark cleanup adds braces, uses a nonmutating sort and removes a synchronous await. Core/UI/plugin/script/test typechecks, formatting, boundary checks, runtime import cycles and dead-export scans passed. Finalgit diff --checkis clean.The full local
pnpm buildpassed in 6m 19s and the packaged-worker benchmark passed. Initial-head CI 44222426669 skippedbuild-artifacts; no build success is inferred from that skip. It caught the missing packageworkerEntriesdeclaration, now fixed at its metadata owner: production/full-tree unused-file scans and 19 build-entry tests pass.The remaining initial-run UI failure is proven inherited:
ui/src/e2e/chat-heartbeat-activity-rollup.e2e.test.ts:61expects “Heartbeat Respond” but renders “Used tools”. The same focused browser test fails on both the candidate and exact main parentfd2949d747c11a671676a1697232d67a6614772d, using a clean detached checkout and its own frozen dependency installation. Commit 18136c960eaf7 / PR #198133 introduced that assertion. This was a main regression, now repaired on newer main by 375daf6d3c3de / #200897. This lane does not duplicate that repair or treat the failure as noise. Final-head CI 44225226137, attempt 1 at9d07b6fec8286783180905d197d87caf66d21087, completed with a different failure:boot-module-boundaries.e2e.test.ts/ “keeps pending Inbox intent current across navigation”, atnative-module-boundaries.test-support.ts:136(dialog count remains 1 after Escape). Focused browser replays passed on both the exact parent and candidate. That does not prove a fix or establish inherited attribution; the CI failure remains unresolved and is not eligible for the inherited-red exception. The lead classified this as a hosted intermittent and authorized one failed-job-only rerun. Attempt 2 passed, including UI job134547388653 and the aggregate CI gate, on the unchanged exact head9d07b6fec8286783180905d197d87caf66d21087. No inherited-red exception is used; the first failed attempt remains recorded.Codex autoreview of the local candidate against
fd2949d747c11a671676a1697232d67a6614772d: scoped clean through P2, no accepted/actionable findings. A fresh Codex review of the five-line worker-entry declaration is also clean through P2. Performance acceptance is not implied by either correctness review.Final-head ClawSweeper reported no actionable code findings; its performance-cost decision is now explicitly accepted by the owner. Re-review is requested to reconcile that item. No merge has been submitted.