Skip to content

perf(workers): speed up remote workspace captures with many files - #144017

Merged
steipete merged 1 commit into
mainfrom
codex/bounded-remote-manifest-hashing
Sep 10, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/bounded-remote-manifest-hashing

Conversation

@steipete

@steipete steipete commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #134931.

What Problem This Solves

Remote workspace captures spend unnecessary time opening and hashing many small files, including captures that can reuse remembered hashes. If a read fails and closing its handle also fails, the close error can hide the original cause.

Why This Change Was Made

Use up to four concurrent readers within the existing opened-byte budget and file-growth checks. The first failure stops new admission, aborts active reads, and is reported only after pending opens and handle cleanup settle. Manifest ordering, memo selection, and publication remain unchanged.

User Impact

Many-file workspace captures can finish sooner without a new setting. Local measurements saved 77–105 ms for 2,048 small files; a workload dominated by one large file was effectively unchanged. These are capture timings, not whole-session startup measurements.

Evidence

  • Three new real-file cases demonstrate red-to-green failures and cover bounded overlapping readers, deterministic cold-hash/memo-hit output, pending-open settlement, active-reader cancellation, first-error preservation, closed handles, and no publication after failure.
  • All 17 focused owner/sibling cases passed. The full changed-file gate passed without skips, and a fresh independent P2 review found no actionable issue.
  • Local macOS benchmark: five alternating pairs per case/mode, 60 measured runs. For 2,048 × 4 KiB files, median total capture time fell from 277.4 to 172.8 ms with an empty hash memo, and from 192.2 to 115.2 ms on memo hits. Every manifest, file hash and memo matched independently. OS caches were uncontrolled; an empty memo is not a cold disk cache.
  • Fresh AWS/Linux proof passed on this exact commit: 42 actual generated-script captures on one m7a.large VM with Node24.20.0, including 36 measured runs (three alternating pairs per workload/memo mode) and six warm-ups. An independent oracle checked every file hash, mode, size, manifest, stat-derived memo and hit/hash count. The IMDSv2 no-role check passed. The VM was confirmed released with complete cleanup; all eight host commands and remote child processes settled, scratch was removed, and root independently verified process absence plus all137,476 dependency entries and40,682 tracked source files unchanged.
  • For 2,048 × 4 KiB files on that VM, median producer capture time fell from326.7 to252.0ms with an empty memo and from177.5 to120.3ms on memo hits. Observed child completion fell from370.2 to319.4ms and242.7 to193.5ms respectively. Medium and64MiB-dominated observed completion was effectively unchanged. Producer capture uses its own totalDurationMs; child completion additionally includes Node startup and supervisor polling. OS caches were uncontrolled, and one VM/three pairs does not establish a general speedup.
  • The original CI merge failed on unrelated documentation navigation. Existing repair fix(docs): align locale navigation with split release tabs #144037 is now merged; fresh merge CI passed with its actual preflight checkout verified against repaired main and this exact hashing commit unchanged. An earlier refresh retained GitHub’s stale merge SHA and was canceled after its preflight exposed the mismatch. The old failed/canceled runs remain recorded.

This is a two-file extraction from the original combined work. It adds 26 net production lines and three regression cases; no configuration, schema, wire-format, or workspace acceptance change is included. Overlapping per-file hash durations measure effort; total capture duration remains the wall-time measure. No changelog edit is needed before release generation.

Hash up to four eligible workspace files concurrently while preserving the
opened-byte budget, growth checks, deterministic manifests, and memo format.
Stop admitting work on the first failure, abort active readers, and join
pending opens and handle cleanup before returning the original error.

This extracts a small independent piece from #134931. Local many-file
capture benchmarks saved 77-105 ms on the 2,048-file fixture; large-file
capture was unchanged. Seventeen focused cases, the full changed-file gate,
and independent review passed. Real Linux/AWS qualification is pending.
@steipete steipete self-assigned this Sep 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 10, 2026
@steipete
steipete marked this pull request as ready for review September 10, 2026 12:09
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 10, 2026
@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 10, 2026, 9:23 AM ET / 13:23 UTC (Revision 3).

ClawSweeper review

What this changes

Remote workspace captures read up to four files concurrently and preserve the first failure while finishing outstanding reads and closing handles.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused PR: current main still hashes remote files sequentially, and the supplied production-script measurements support the improvement. No actionable correctness or security finding remains; the previous benchmark caveat does not require contributor action.

Priority: P2
Reviewed head: f8cab569749e428fd049891fd88305f6e5f1472d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with strong runtime measurements, meaningful failure coverage, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured body reports actual generated-script captures on macOS and AWS/Linux at this head, with independent manifest/hash/memo checks and observed many-file improvements; the failure-path tests supplement that production-path evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body reports actual generated-script captures on macOS and AWS/Linux at this head, with independent manifest/hash/memo checks and observed many-file improvements; the failure-path tests supplement that production-path evidence.
Evidence reviewed 8 items Introduced implementation and publication boundary: The complete script preserves opened-byte accounting, no-follow opens, file-growth checks, and before/after stat identities. Its bounded workers retain the first error and join before main can publish a manifest. No configuration, persistent format, or authority contract changes.
Current main still needs this improvement: The fetched main implementation retains a sequential file loop and a finally-close operation that can replace a read error. The introduced concurrency and first-error handling are absent.
Latest release comparison: The v2026.9.3 source also hashes files sequentially. Its blob was unavailable locally, so the release source was inspected through GitHub's contents API.
Findings None None.
Security None None.

How this fits together

Cloud workers capture file hashes and metadata so the Gateway can reconcile remote workspace changes. The capture script consumes eligible files and remembered hashes, then returns a deterministic manifest reference and updated hash memo.

flowchart TD
  A[Workspace capture request] --> B[Select eligible files]
  B --> C[Up to four file readers]
  D[Remembered hashes] --> C
  C --> E{All reads succeed?}
  E -->|Yes| F[Publish ordered manifest and memo]
  E -->|No| G[Abort reads and close handles]
  G --> H[Report first failure]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +26, Tests +204. Total +230 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 67 41 +26
Tests 1 204 0 +204
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 271 41 +230

Review metrics

Metric Value Why it matters
Implementation cost Production +26 net lines; tests +204 lines Production growth implements bounded admission and joined cleanup; the tests protect observable concurrency and failure behavior.

Technical review

Best possible solution:

Keep bounded concurrency within the existing remote capture owner while preserving deterministic output, byte limits, and settled cleanup before publication.

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

Yes, from source: current main serializes file reads and can replace a read failure with a subsequent close failure. The added real-file cases target those paths; no tests were executed during this review.

Is this the best way to solve the issue?

Yes. The patch updates the existing standalone capture script, preserves its caller and serialization contracts, and adds bounded cleanup without introducing a competing capture path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a measured workspace-capture improvement with bounded scope and no demonstrated urgent user outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured body reports actual generated-script captures on macOS and AWS/Linux at this head, with independent manifest/hash/memo checks and observed many-file improvements; the failure-path tests supplement that production-path evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body reports actual generated-script captures on macOS and AWS/Linux at this head, with independent manifest/hash/memo checks and observed many-file improvements; the failure-path tests supplement that production-path evidence.

Evidence

What I checked:

  • Introduced implementation and publication boundary: The complete script preserves opened-byte accounting, no-follow opens, file-growth checks, and before/after stat identities. Its bounded workers retain the first error and join before main can publish a manifest. No configuration, persistent format, or authority contract changes. (src/gateway/worker-environments/workspace-sync-scripts.ts:354, f8cab569749e)
  • Current main still needs this improvement: The fetched main implementation retains a sequential file loop and a finally-close operation that can replace a read error. The introduced concurrency and first-error handling are absent. (src/gateway/worker-environments/workspace-sync-scripts.ts:354, c973fe7e7219)
  • Latest release comparison: The v2026.9.3 source also hashes files sequentially. Its blob was unavailable locally, so the release source was inspected through GitHub's contents API. (src/gateway/worker-environments/workspace-sync-scripts.ts:354, 1391f7cd2d40)
  • Real capture evidence: The complete captured PR body, sourceRevision a95159304de59164b9bba62384d70d6806ae71e501d51520f25d1a89420a773f, reports 42 executions of the actual generated capture script on AWS/Linux at this head, with independently checked hashes, modes, sizes, manifests, memos, and counters. Many-file producer medians improved from 326.7 to 252.0 ms without memo and 177.5 to 120.3 ms with memo. macOS measurements provide additional evidence. These are bounded workload observations with uncontrolled OS caches, not general startup guarantees. (f8cab569749e)
  • Regression coverage at the generated-script boundary: Read all three added cases and the existing inventory-limit tests. They exercise real descriptors and streams, deterministic cold/memo output, pending-open settlement, active-reader cancellation, first-error preservation, and absence of publication after failure. The body reports 17 focused cases passing; this read-only review did not execute tests. (src/gateway/worker-environments/workspace-sync-hashing.test.ts:19, f8cab569749e)
  • Existing owner and deterministic output: The capture caller executes this standalone Node script and validates its response before replacing worker memo entries. Existing memo selection sorts identities, and manifest serialization sorts paths, so completion order does not change serialized output. The local Gateway scanner is a separate adapter; its existing concurrency does not replace this remote script. (src/gateway/worker-environments/workspace-sync-helpers.ts:217, f8cab569749e)

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 (2 earlier review cycles)
  • reviewed 2026-09-10T12:15:53.050Z sha f8cab56 :: blocked before merge. :: none
  • reviewed 2026-09-10T12:29:14.303Z sha f8cab56 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 10, 2026
@steipete steipete closed this Sep 10, 2026
@steipete steipete reopened this Sep 10, 2026
@steipete steipete closed this Sep 10, 2026
@steipete steipete reopened this Sep 10, 2026
@steipete steipete changed the title improve: speed up remote workspace captures with many files perf(workers): speed up remote workspace captures with many files Sep 10, 2026
@steipete
steipete merged commit 28800b2 into main Sep 10, 2026
529 of 636 checks passed
@steipete
steipete deleted the codex/bounded-remote-manifest-hashing branch September 10, 2026 13:38
@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 11, 2026
Capture remote workspace files with at most four concurrent readers while preserving the existing opened-byte budget, growth checks, deterministic manifest/memo output, and publication boundary. Stop admission on the first failure, abort active streams, and join pending opens and handle cleanup before returning that original error.

Three demonstrated red-to-green regressions, 17 focused cases, the full changed-file gate and independent review passed. Actual AWS/Linux proof completed 42 captures with independently verified output and complete resource cleanup. For 2,048 small files, producer capture medians improved 326.7 to 252.0 ms without memo and 177.5 to 120.3 ms with memo; larger-file observed completion was effectively unchanged. These measurements cover one VM with uncontrolled OS caches, not overall session startup.

Extracted from openclaw#134931. The original CI merge failed on unrelated documentation navigation; openclaw#144037 repaired that shared prerequisite, and the qualified hashing commit was preserved for fresh merge CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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