Visitar URL original
improve(browser): skip unused default snapshot reconstruction by steipete · Pull Request #152801 · openclaw/openclaw · GitHub
Skip to content

improve(browser): skip unused default snapshot reconstruction - #152801

Merged
steipete merged 1 commit into
mainfrom
codex/perf-r2-browser-snapshot-lines-20260919
Sep 20, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-r2-browser-snapshot-lines-20260919

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Default native AI browser snapshots build an output-line array and reconstruct the entire text even though their caller uses only the generated refs and retains the original snapshot.

User Impact

Default snapshots avoid those unused copies while preserving supported snapshot text, refs, parsing failures, and publication behavior. Browser-side behavior, connection policy, public options, and configuration are unchanged.

Why This Change Was Made

The existing builder skips output accumulation only when options are omitted or explicitly undefined. It still parses and decodes every admitted line, including lines beyond the final output budget. Explicit option objects retain their existing filtering and accumulation path; no split-array mutation, second parser, or cache is introduced. The duplicate adjacent doc comment is removed.

The helper is internal and has no SDK export. Explicit option getters keep their observation order. Its JavaScript arity changes from 1 to 2, and arbitrary global Object.prototype option defaults are not preserved universally; neither has a supported caller in the source trace.

Evidence

Current-source qualification: source inspection at main a3cfeb826aeccf84be6c802f60103591c28109d9 found the builder, snapshot callers, registered route, delta/ref publication and consumed helper contracts unchanged; Playwright remains 1.63.0. The local tests and timings below retain their original source/dependency attribution. Exact-head CI run 35440636043 passed. Mixed ordinary/dense results and unmeasured end-to-end browser latency are accepted, disclosed limits of this bounded cleanup, not a general speedup claim.

103 focused tests passed (100 existing plus three preservation cases), plus six mapped contract tests. Extension production/test types, lint, formatting, and applicable changed-file guards passed. Fresh isolated Codex review found no actionable P0–P2 issue.

A synthetic registered /snapshot route used the real preparation, builder, finalizer, delta cache, and ref-publication owners, using a synthetic Page, connection lookup, and the supported custom profile-context boundary. Twelve ordinary result graphs and ten edge graphs match the original, including published/returned ref aliases, malformed-tail errors, and frame-change rejection. No real browser or third-party target was exercised.

Fixed temporal ABBA ×3 measurements used 12 fresh processes and 4,320 measured operations. Long prose improved 8.20% wall time and 8.33% CPU in all six pairs; pooled large capped/uncapped cases also improved. Results remain mixed: ordinary and dense cases were adverse; 26/72 wall pairs, 28/72 CPU pairs, and 18/72 RSS pairs were adverse. Five of twelve pooled wall cells and five CPU cells were adverse. This is not a general browser speedup or isolated-memory claim.

The rejected in-place-compaction experiment remains retained separately, including its 29/72 adverse wall pairs, 29 CPU pairs, 21 RSS pairs, and slightly adverse pooled large cases. Only this narrower alternative followed; no selective cases or outlier removal.

Complete final measurement matrix and scope

Positive change is adverse. Node 26.8.2, macOS arm64. Timings include local route execution, response/event bookkeeping, and a constant-time ref-alias assertion; Page/context construction and full graph equality checks are outside clocks. RSS covers the broader worker/import scope. Fixed case order and shared-host activity limit attribution. This does not measure network latency or real connection admission. The document-change edge tests rejection during capture; existing delta tests separately cover baseline reset.

Case Wall A→B (µs/call) CPU A→B (µs/call) RSS A→B (MiB) Wall/CPU/RSS change % Adverse pairs W/C/R
empty 32.696→30.104 50.500→52.800 1017.156→1009.328 -7.93/+4.55/-0.77 3/6 / 3/6 / 3/6
ordinary 140.671→144.963 313.200→342.100 1020.062→1016.602 +3.05/+9.23/-0.34 3/6 / 5/6 / 3/6
dense 929.379→951.642 1357.800→1462.600 1042.250→1027.938 +2.40/+7.72/-1.37 2/6 / 4/6 / 3/6
large-capped 7354.046→7023.625 7842.700→7586.300 1056.172→1040.703 -4.49/-3.27/-1.46 1/6 / 1/6 / 3/6
large-uncapped 11822.000→11599.454 12325.800→12067.700 1088.031→1071.414 -1.88/-2.09/-1.53 2/6 / 2/6 / 3/6
long-prose 1608.787→1476.796 1609.800→1475.700 1118.117→1083.359 -8.20/-8.33/-3.11 0/6 / 0/6 / 0/6
quoted-duplicates 1088.183→1069.738 1546.300→1626.600 1127.430→1086.258 -1.70/+5.19/-3.65 1/6 / 2/6 / 1/6
depth-control 457.375→446.754 826.000→701.200 1131.055→1086.867 -2.32/-15.11/-3.91 2/6 / 1/6 / 1/6
compact-control 1128.829→1157.750 2017.900→1999.200 1133.727→1088.211 +2.56/-0.93/-4.01 3/6 / 2/6 / 1/6
interactive-control 841.446→846.433 928.600→959.600 1135.797→1089.500 +0.59/+3.34/-4.08 5/6 / 3/6 / 0/6
blank-lines 81.692→79.542 82.100→81.000 1136.977→1090.406 -2.63/-1.34/-4.10 1/6 / 1/6 / 0/6
same-document-delta 1037.662→1062.237 1441.300→1351.700 1140.062→1091.328 +2.37/-6.22/-4.27 3/6 / 4/6 / 0/6

@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@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 Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 19, 2026, 11:26 PM ET / September 20, 2026, 03:26 UTC (Revision 4).

ClawSweeper review

What this changes

The browser snapshot builder skips rebuilding unchanged text when options are omitted, while preserving reference extraction, filtering, and parsing errors.

Merge readiness

✅ Ready for maintainer review

This remains a useful, bounded cleanup absent from current main and the latest release. No actionable correctness defect was found; the maintainer has already accepted the disclosed measurement limitations.

Priority: P3
Reviewed head: 8192db4fd842365863244c25a13dc4035b5ac9e0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving cleanup with useful boundary coverage and appropriately limited performance claims.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its synthetic registered snapshot route exercises the changed builder and downstream finalization/publication, but does not establish real-browser latency; that limitation is explicitly accepted in discussion.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its synthetic registered snapshot route exercises the changed builder and downstream finalization/publication, but does not establish real-browser latency; that limitation is explicitly accepted in discussion.
Evidence reviewed 7 items Introduced change verified: The pinned merge-base-to-head patch changes output accumulation only when options are undefined; line parsing, name decoding, reference validation, and explicit-option filtering remain in place.
Production callers preserve the intended boundary: The default AI snapshot caller consumes built.refs while passing the original snapshot to finalization. The role snapshot caller passes opts.options and consumes the builder's text. Both retain finalization and frame checks before reference publication.
Optimization remains absent from fetched main: The fetched main revision still allocates the output array, appends every retained line, and joins it even when options are omitted.
Findings None None.
Security None None.

How this fits together

The browser plugin converts Playwright page snapshots into text and element references for agent actions. Its finalizer applies output limits before publishing the references used by subsequent browser interactions.

flowchart LR
  A[Browser snapshot request] --> B[Playwright page snapshot]
  B --> C[Parse element references]
  C --> D{Options supplied?}
  D -->|No| E[Reuse original text]
  D -->|Yes| F[Filter and reconstruct text]
  E --> G[Apply output limits]
  F --> G
  G --> H[Return snapshot and publish references]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +28. Total +30 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 8 6 +2
Tests 2 28 0 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 36 6 +30

Review metrics

None.

Technical review

Best possible solution:

Keep one snapshot parser and avoid unused text reconstruction without changing supported output, reference publication, or filtering contracts.

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

Not applicable as a bug reproduction: source confirms the unused reconstruction, and the supplied measurements describe a bounded optimization rather than a functional failure.

Is this the best way to solve the issue?

Yes. The change stays inside the existing builder, retains complete parsing, and preserves the explicit-option path without introducing another parser or public API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 598c57cec48e.

Labels

Label justifications:

  • P3: This is an internal allocation cleanup with no intended user-visible behavior change or urgent regression.
  • 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: The maintainer-authored PR is exempt from the external-contributor proof gate. Its synthetic registered snapshot route exercises the changed builder and downstream finalization/publication, but does not establish real-browser latency; that limitation is explicitly accepted in discussion.

Evidence

What I checked:

  • Introduced change verified: The pinned merge-base-to-head patch changes output accumulation only when options are undefined; line parsing, name decoding, reference validation, and explicit-option filtering remain in place. (extensions/browser/src/browser/pw-role-snapshot.ts:490, 8192db4fd842)
  • Production callers preserve the intended boundary: The default AI snapshot caller consumes built.refs while passing the original snapshot to finalization. The role snapshot caller passes opts.options and consumes the builder's text. Both retain finalization and frame checks before reference publication. (extensions/browser/src/browser/pw-tools-core.snapshot.ts:300, 8192db4fd842)
  • Optimization remains absent from fetched main: The fetched main revision still allocates the output array, appends every retained line, and joins it even when options are omitted. (extensions/browser/src/browser/pw-role-snapshot.ts:517, 598c57cec48e)
  • Latest release still reconstructs default text: The same unconditional output-array and join path is present in v2026.9.5; this optimization is not already shipped there. (extensions/browser/src/browser/pw-role-snapshot.ts, ec9c1a13db89)
  • Preservation coverage: The added boundary test requires malformed names beyond the output budget to throw before references are stored. The other added cases preserve raw line boundaries with explicit empty and depth-filter options. These are behavior-preservation checks; tests were inspected, not executed in this read-only review. (extensions/browser/src/browser/pw-tools-core.snapshot.test.ts:478, 8192db4fd842)
  • Proof scope and prior-review disposition: The captured body reports synthetic registered-route comparisons covering twelve ordinary and ten edge result graphs, plus mixed timing results; it explicitly excludes real-browser and end-to-end latency claims. The supplied September 20 maintainer comment accepts those limits for this cleanup. The previous completed review records no findings or published rank-up moves. (8192db4fd842)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-19T11:00:27.774Z sha 8192db4 :: blocked before merge. :: none
  • reviewed 2026-09-19T11:42:19.243Z sha 8192db4 :: blocked before merge. :: none
  • reviewed 2026-09-20T02:20:17.663Z sha 8192db4 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 19, 2026 11:37
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Maintainer assessment: the mixed ordinary/dense measurements and unmeasured end-to-end browser latency remain disclosed limitations, not a correctness finding or an additional proof requirement for this bounded cleanup. The builder still parses every line and builds refs; it skips only unused text reconstruction when options are absent. No general browser speedup or isolated-memory benefit is claimed.

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit 8be7dd9 into main Sep 20, 2026
162 checks passed
@steipete
steipete deleted the codex/perf-r2-browser-snapshot-lines-20260919 branch September 20, 2026 03:27
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: browser 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