Skip to content

perf(workspace): trim redundant writer request payloads - #187076

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-local-workspace-request-bytes-20261028
Oct 28, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-local-workspace-request-bytes-20261028

Conversation

@steipete

@steipete steipete commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Local sandbox workspace admission and checkpoint settlement resend expanded inventories to the SQLite writer after their content is already prepared.

User Impact

No storage format or reconciliation behavior changes. Workspace writes send less data between the host and writer; full checkpoint documents remain durable for recovery.

Why This Change Was Made

The workspace store now sends only the manifest root publication fields consumed by the writer. A checkpoint also contains recovery documents and build-input arrays, which previously crossed this boundary because its structural type fits the mutation interface. Source-path creation and updates send the existing [] storage placeholder after content-addressed preparation, while the original mutation retains the complete JSON for host publication and lost-reply recovery.

No schema, durability, FIFO ordering, authorization, revision, or lease checks change. Production delta: +25 lines (31 added, 6 removed). The added projection preserves the separate contracts: full host receipt reconstruction and compact writer input; it adds no cache or alternate persistence path.

Evidence

The new real-store regression fails on main 9cd97293eb93e0d445481a08ccbe94d5ae52ce63: create 48,009 B, settlement 53,824 B, both over the 2,048 B request budget. It passes with this change and verifies exact durable readback and retained checkpoint content.

Synthetic workload: 16 retained workspace rows, 1,000 admitted build-input paths, prepared roots differing in one file, source admission, checkpoint reservation, settlement, and cleanup through the real store and SQLite broker. Byte measurements use 32 cycles; MB/min below uses a declared 30 cycles/minute, not benchmark throughput or a claim about production operation mix.

Writer operation Base MB/min Candidate MB/min
Source preparation 0.025065 0.025065
Source admission 1.420620 0.012030
Checkpoint reservation 1.463790 1.463790
Settlement 1.428540 0.019260
Cleanup 0.010620 0.010620
Total 4.348635 1.530765

64.8% fewer request bytes. Source-admission mutation: 47,354 → 401 B/request. Settlement: 47,618 → 642 B/request. Create setup: 48,086 → 1,138 B/request. Content preparation and saved checkpoint traffic are unchanged.

Rerun instructions are in scripts/perf/local-workspace-request-bytes-measure.ts. --revision <base-sha> substitutes only the old store owner. Byte-count instrumentation is disabled during timing and allocation measurements.

Owner measurements use 2,048 cycles per arm, AB/BA order, with timing and allocation collected separately. Mixed-sign initial CPU pairs triggered one predeclared extra untraced pair.

Metric Base Candidate Change
Untraced main-thread CPU, three pairs 4,796.10 µs/cycle 4,948.31 µs/cycle +152.21 µs (+3.17%)
Sampled main-thread V8 allocation, two pairs 1,056,370 B/cycle 1,058,317 B/cycle +1,947 B (+0.184%)
Elapsed per 2,048-cycle arm, three pairs 27.802 s 32.778 s +17.90%

This demonstrates a request-byte reduction, not a CPU or V8-heap allocation win. CPU pair differences were −110.28, +441.78, and +125.14 µs/cycle. Wall-time differences were +5.32%, +44.48%, and +1.89%; host/runtime drift was large. No rejection is inferred from these mixed measurements. The main-thread heap sampler does not account for all external serialization backing buffers or worker allocations.

Per-arm context (A = base, B = candidate)
Arm CPU µs/cycle Sampled B/cycle Elapsed s Host load start→end Endpoint RSS / heap MiB
Timing A1 6,489.35 — 37.541 22.59→23.40 710.55 / 83.06
Timing B1 6,379.06 — 39.538 23.02→26.73 686.80 / 80.86
Timing B2 5,415.19 — 40.932 26.58→35.43 693.32 / 70.15
Timing A2 4,973.41 — 28.331 39.26→35.63 703.89 / 69.81
Timing A3 2,925.55 — 17.533 14.57→15.79 709.94 / 94.06
Timing B3 3,050.69 — 17.865 14.81→14.99 689.43 / 65.78
Allocation A1 3,262.90 1,055,293 18.179 30.89→26.47 710.89 / 70.98
Allocation B1 3,979.84 1,056,522 23.698 20.23→23.30 721.63 / 71.44
Allocation B2 4,122.99 1,060,112 23.228 19.85→18.89 707.78 / 71.03
Allocation A2 3,083.41 1,057,447 17.608 17.37→16.15 736.82 / 72.25

Traced-pass CPU averages +27.68%; this instrumentation pass is context, not the untraced timing verdict. RSS/heap are endpoint observations, not post-GC retention proof.

Validation: pnpm tsgo:test:root, the matching Gateway test typecheck, changed-file lint/format, export collision guard, and diff whitespace checks passed. Store, manifest-scan, and projection files passed 83 tests, with two environment-dependent skips (required Podman and invalid-UTF-8 filesystem support). Wall time 156 seconds including worker compilation; regression test time is under one second. Test-lines ratchet passed: 6,312,380 / 6,320,000. The two required import/source-closure files passed 38 tests (57 seconds). Independent subagent review (autoreview route unavailable) found no P0–P2 findings; the configured autoreview route was refused before inference, and operator configuration was left unchanged.

Scope: owner-boundary proof, not whole-Gateway performance. No live service was stressed. Under this lane's bounded-transport fast-path protocol, no ten-minute Gateway campaign was run; server handler latency, event-loop tails, whole-Gateway GC/CPU, and production MB/min remain unmeasured.

Exact-head CI is green on dcffa652538461751755f6721d94c6fc44aa38ee: CI run. Hosted review and security checks passed. This PR is ready and intentionally left unmerged for maintainer review.

Publish only prepared manifest root fields to the writer and send the existing digest-backed source-path placeholder. Keep full checkpoint and admitted-path data for durable recovery and host publication.

Real-store byte-budget regression fails on main and passes with the fix. Synthetic owner workload reduces request bytes by 64.8%; sampled main-thread allocation is neutral and timing varies with host load.
@clawsweeper

clawsweeper Bot commented Oct 28, 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.

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Contributor

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-28T23:11:28.733077Z dcffa65 PR opened
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts size: M labels Oct 28, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR sends compact workspace publication requests while retaining complete source paths and checkpoint documents for recovery.

Example: A workspace checkpoint contains 1,000 admitted build-input paths.

  • Before: The supplied measurement reports a 47,618-byte settlement request containing redundant checkpoint data.
  • After: The settlement request is 642 bytes, while the saved checkpoint retains its complete recovery document.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is correct on inspection and supported by real-store measurements and regression coverage; evidence establishes request-byte reduction rather than whole-Gateway performance.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied owner-boundary measurements exercise source admission, checkpoint reservation, settlement, cleanup, and durable readback through the real store and SQLite broker.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Workspace synchronization transfers expanded inventories to the writer after their content is already prepared.
Reason: The maintainer-authored direction removes measurable redundant traffic with a small production change and no new configuration, persistence owner, or public contract.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR removes verified redundant writer payloads, and review found no actionable correctness or security defects.

Priority: P2
Reviewed head: dcffa652538461751755f6721d94c6fc44aa38ee

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supplied proof exercises the real store and SQLite broker rather than a shipped Gateway reconciliation flow.
Agent review details

How this fits together

The Gateway workspace store prepares content-addressed inventories, submits mutations to the SQLite writer, and reconstructs acknowledged projections for synchronization and recovery.

flowchart LR
  A[Workspace reconciliation] --> B[Local workspace store]
  B --> C[Content preparation]
  C --> D[SQLite writer]
  B --> E[Compact publication request]
  E --> D
  D --> F[Commit receipt and host projection]
Loading

Technical review

Best possible solution:

Keep compact request construction in the existing workspace store and preserve complete host publication and durable recovery data.

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

Source shows complete checkpoints and source-path JSON entering writer requests despite prepared content; the supplied regression reports base failure and candidate success, but this read-only review executed no target code.

Is this the best way to solve the issue?

The patch removes redundant data at its existing producer while preserving the writer, preparation, receipt reconstruction, compression, and recovery owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4a2a1962d9ca.

Provenance checked

  • Content-addressed source-path publication keeps the original intent (a25b072: Prepare shared compressed source-path sets and publish their digest while retaining existing document bytes.)
  • Owned mutation handoff and receipt recovery keeps the original intent (ce503a5: Avoid full mutation copies while retaining complete owner-held inputs for acknowledged publication and lost-reply recovery.)
  • Completed mutation capture lifecycle keeps the original intent (6592064: Release completed payload captures while preserving committed facts needed after transport settlement.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit cd326f9 adds src/gateway/worker-environments/local-workspace-store.ts:145 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cd326f915580; files: src/gateway/worker-environments/local-workspace-store.ts)

PR surface

Source +25, Tests +59, Other +322. Total +406 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 31 6 +25
Tests 1 59 0 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 322 0 +322
Total 3 412 6 +406

Labels

Label changes:

  • add P2: A focused workspace transport optimization reduces redundant data without an established urgent user-facing outage.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A focused workspace transport optimization reduces redundant data without an established urgent user-facing outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 28, 2026, 7:24 PM ET / 23:24 UTC.

@steipete
steipete merged commit 5516b90 into main Oct 28, 2026
151 of 153 checks passed
@steipete
steipete deleted the steipete/perf-local-workspace-request-bytes-20261028 branch October 28, 2026 23:29
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
)

Publish only prepared manifest root fields to the writer and send the existing digest-backed source-path placeholder. Keep full checkpoint and admitted-path data for durable recovery and host publication.

Real-store byte-budget regression fails on main and passes with the fix. Synthetic owner workload reduces request bytes by 64.8%; sampled main-thread allocation is neutral and timing varies with host load.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M 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