Skip to content

perf: skip discarded Readability HTML in text mode - #134452

Merged
steipete merged 1 commit into
mainfrom
codex/perf-readability-text-serialization-20260831
Aug 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-readability-text-serialization-20260831

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Readability builds a final HTML string even when web fetch requests plain text and discards that HTML. Text extraction pays for a serialization it does not use.

Why This Change Was Made

Use Readability's existing serializer option only in text mode. Its actual parser computes text and metadata before invoking the final serializer. Markdown still passes undefined options and uses the default serializer. Size/depth guards, sanitizer, lazy imports, title handling, normalization, fallback ordering and public output stay unchanged.

The owning plugin keeps one extraction path with no cache, new dependency, setting, SDK surface or persistence change. Production is +7/−6, net +1 line, including an explanatory ownership comment; tests are unchanged. The extra mode fact selects the supported dependency behavior and replaces the later repeated comparison. An earlier internal Readability serialization remains untouched, so this does not remove all HTML serialization.

User Impact

Less local parsing work for text-mode web fetch. Default Markdown behavior is retained. This is an internal performance refactor, not a new operator-facing feature or configuration change.

Evidence

The complete extractor was measured with the actual installed Readability 0.6.0, Linkedom 0.18.13 and SDK helpers. No parser, sanitizer, renderer or loader replacement. Correctness covers 88 paired HTML/mode cases, ten request/order/error controls, two actual-dependency serializer controls and all 20 workload oracles. Independent source review checked the full parser and relevant DOM serialization implementation, canonical primitive request producer, callers, siblings, history and emitted dependency graph.

A fixed 16-process replication used eight before and eight candidate processes in counterbalanced order. All 3,520 measured samples, 1,280 warmups, 320 medians and 4,816 journal entries are retained and independently recomputed. Aggregates below are medians of eight process medians per variant, not pooled samples.

Complete extraction Before → candidate Change Slower adjacent pairs
Ordinary text 214.960 → 205.344 µs −4.47% 0/8
Medium text 815.604 → 765.104 µs −6.19% 0/8
Large text 3183.104 → 3015.083 µs −5.28% 0/8
Small text 530.579 → 533.444 µs +0.54% 4/8
Unicode Markdown 361.976 → 364.049 µs +0.57% 4/8

The predeclared gate required at least 3% aggregate improvement for medium/large text and rejected any accepted Markdown row with more than 3% cost plus at least six of eight slower pairs. It passed without changing source, workload, sampling or decision rules. No rows were dropped or retried. All other controls and costs remain in the complete 20-row report.

The earlier four-process batch is retained separately: it showed a 5.57% pooled small-Markdown cost and a 3.43% links-Markdown cost. Replication did not consistently repeat those costs; it does not erase them or establish a noise cause. The replicated first lazy extraction costs 36.074 → 37.084 ms; imports follow dependency hashing and are not a cold-filesystem measurement. No default-Markdown, whole-Gateway, startup, retained-memory or statistical-significance claim.

Source capture remains 0959561 and measured execution remains 2fb3364. A separate current-main e42e600 audit matched all 29 other root pins, 33 immutable copies, 1,159 installed files and 33 resolution identities; the thirtieth root pin, package.json, only adds unrelated pricing SDK export/package metadata. The integrated source differs from measured R2 only by the repository formatter and a comment; comment-free single-file compilation is byte-identical.

The baseline and candidate each pass 24 canonical tests across the extractor, dispatch/lifecycle, plugin registry and web-fetch neighborhood. The first changed-code check stopped on formatting; the repository formatter corrected that presentation-only issue. Fresh managed Codex review is scoped-clean at P0, supplemented by the independent all-priority source and raw-evidence reviews. The full changed-code check rerun passed in 183.420 seconds. Commit 9eaec78 is the reviewed candidate. Its full build passed in 169.885 seconds, and a fresh committed Codex review is scoped-clean at P0 (0.99). Hosted CI run 33435590742, attempt 1, passed on that exact head without a retry.

The exact-head built Gateway completed four real OpenAI turns on the first run: readiness, batched Tool Search, search plus a literal file read, and search plus two sequential web fetches. The task-owned SQLite transcript independently confirms the default Markdown request omitted extractMode and the second requested text. Both fetched the public Node performance documentation with HTTP 200 through Readability, producing distinct 97,622-character Markdown and 66,195-character text bodies, each visibly capped at 2,000 characters with the full content retained in private task artifacts. Three event RPCs, two status projections and twelve session RPCs also passed. Direct checks found the Gateway PID/group and socket gone; temporary config and key FIFO were removed. Default-named CPU profiles distinguish the main thread (19,577 samples) from a separate worker profile. These are integration/diagnostic observations, not comparative Gateway latency or all-thread profiling claims. No user/operator configuration or saved session was changed.

ClawSweeper follow-through: the complete 20:30 review reported no code/security finding, but its environment could not inspect the pinned dependency and still saw a pending extension check. The lead and independent reviewer directly read installed Readability 0.6.0; a fresh upstream fetch is byte-identical (SHA-256 34dcab3d0832d0019f02990eed6b6124e029e8c32b9f0c6f2550544ff8dff174). The constructor's serializer option defaults to innerHTML, and parse captures text before final serialization. Actual dependency controls and the real two-mode Gateway run also pass. Its only Rank-up move—finish exact-head changed-extension CI—is satisfied by successful run 33435590742. A later automated review refresh is queued; no unresolved source or proof finding is being skipped.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 4:30 PM ET / 20:30 UTC.

ClawSweeper review

What this changes

This PR avoids generating Readability’s final HTML string for text-mode web fetches while preserving the existing markdown extraction path.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for normal maintainer review and completion of the remaining exact-head check. The maintainer-authored, one-file performance refactor has no source-established correctness or security defect, but the pinned Readability dependency source could not be independently inspected because it is absent locally and network DNS is unavailable.

Priority: P3
Reviewed head: 9eaec78b47de397e5bab18a265553a7ffc9f8f82

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, focused owner-boundary optimization with existing behavior coverage and no concrete review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable: this maintainer-authored internal performance refactor has no external-contributor proof gate; the captured body says real Gateway proof is still pending, so no independent after-fix runtime trace was assessed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable: this maintainer-authored internal performance refactor has no external-contributor proof gate; the captured body says real Gateway proof is still pending, so no independent after-fix runtime trace was assessed.
Evidence reviewed 6 items Introduced production change: The verified PR-introduced hunk makes serializer suppression conditional on text mode, retains the default constructor options for markdown mode, and consumes textContent only in the text branch.
Current main behavior: Current main still constructs Readability without custom options and uses content as the successful-parse guard, so this PR is not already implemented on main.
Caller and owner boundary: The extractor runtime loads enabled plugin extractors and returns the first nonempty text result; the changed code remains inside the owning bundled plugin rather than altering the generic runtime.
Findings None None.
Security None None.

How this fits together

The web_fetch tool sends fetched HTML through enabled plugin extractors until one returns readable text. The bundled Web Readability plugin sanitizes and parses that HTML, then returns text and optional title metadata to web_fetch.

flowchart LR
  A[web_fetch receives HTML] --> B[Extractor runtime loads enabled plugins]
  B --> C[Web Readability plugin]
  C --> D[Sanitize and parse article]
  D --> E{Requested output mode}
  E -->|Text| F[Return normalized article text]
  E -->|Markdown| G[Convert article HTML to markdown]
  F --> H[web_fetch result]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The serializer contract for the pinned Readability 0.6.0 dependency could not be independently re-read in this review environment because its installed source is absent and upstream DNS was unavailable.
  • Complete next step (P2) - No repair lane is needed: this maintainer-authored PR has no concrete code defect, and the remaining action is normal exact-head validation.
Agent review details

Security

None.

PR surface

Source +1. Total +1 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 7 6 +1
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 7 6 +1

Review metrics

Metric Value Why it matters
Production versus test delta production +1 net; tests 0 The small production increase is limited to deriving the already-requested mode once and documenting why text mode bypasses serialization.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the mode-local optimization in the Web Readability plugin, then merge only after the pending changed-extension check confirms the exact head.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the mode-local optimization in the Web Readability plugin, then merge only after the pending changed-extension check confirms the exact head.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this is a performance optimization rather than a report of broken existing behavior; the captured PR body supplies benchmark claims but no independently runnable reproduction was performed in this read-only review.

Is this the best way to solve the issue?

Appears yes: the optimization is contained in the plugin that owns Readability parsing and preserves the markdown default path; independent dependency-source confirmation remains unavailable in this environment.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 10564e2fc971.

Labels

Label changes:

  • add P3: This is a bounded internal performance improvement with no new configuration, API, or user workflow.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this maintainer-authored internal performance refactor has no external-contributor proof gate; the captured body says real Gateway proof is still pending, so no independent after-fix runtime trace was assessed.

Label justifications:

  • P3: This is a bounded internal performance improvement with no new configuration, API, or user workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable: this maintainer-authored internal performance refactor has no external-contributor proof gate; the captured body says real Gateway proof is still pending, so no independent after-fix runtime trace was assessed.

Evidence

What I checked:

Likely related people:

  • unknown: The blamed commit carries this line unchanged from a recorded parent; no introducing author is attributed. (role: carried-forward source line; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the pending changed-extension check finish on the exact PR head before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit fec69b4 into main Aug 31, 2026
123 checks passed
@steipete
steipete deleted the codex/perf-readability-text-serialization-20260831 branch August 31, 2026 20:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: web-readability maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant