Skip to content

perf(workers): cut repeated full-tree workspace hashing - #121365

Merged
steipete merged 2 commits into
mainfrom
steipete/zealous-murdock-eae838
Aug 10, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/zealous-murdock-eae838

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cloud-worker workspace reconciliation performs 4–6 remote and 4–6 gateway full content-hash passes per turn because each late-writer safety fence rebuilds a manifest independently. On large workspaces, unchanged files therefore pay the deterministic hashing cost repeatedly even though the separate fences must remain in place to detect concurrent writes.

Why This Change Was Made

The reconcile lifecycle now owns an in-memory content-hash memo shared by its safety fences. Entries are keyed by the file's stat identity (dev, ino, size, mtimeNs, and ctimeNs), so a fence can reuse a hash only while the filesystem still proves it is the same unchanged inode state. The remote memo crosses the short-lived SSH subprocess boundary in a bounded internal envelope; there is no persistent cache and no public protocol, configuration, or schema change.

The repair also reuses local-node observations inside one preflight pass, hoists git enumeration while retaining per-attempt existence filtering, backs inbound quota polling off from 25 ms to 250 ms with a final authoritative scan, and reports one aggregate debug-duration record for the reconcile lifecycle. The quiescence lifecycle was extracted from a module that had grown beyond 700 lines so the ownership boundary remains reviewable.

User Impact

Cloud-worker workspace reconciliation avoids rehashing unchanged files across its safety fences. In the representative 1,000- and 20,000-file harnesses, deterministic content-hash work fell by 80% remotely (five passes to one) and 75% on the gateway (four passes to one).

Wall-clock results are deliberately more modest: median total time improved in 5 of 8 cases, was near-flat in one, and was slower in two one-file cases amid 7–38% run-to-run spread. The benchmark uses local child processes in place of real SSH handshakes and rsync transfers, so it is evidence for hash-work elimination rather than a production latency guarantee.

Release-note context: cloud-worker workspace reconciliation avoids rehashing unchanged files across safety fences.

Evidence

  • Focused proof after rebasing onto current origin/main: 7 files passed, 60 tests passed.
  • Heavy changed gate: Testbox tbx_01kzmrnh41khp1begchx31dym7, command exit 0. Its linked Actions wrapper was cancelled by external lease cleanup after the remote command returned, so that wrapper is not claimed as green CI.
  • Mandatory uncommitted autoreview: clean, with no accepted or actionable findings.
  • git diff --check origin/main...HEAD: clean.

Representative benchmark totals (baseline versus median of three after-runs):

Files Mode Turn Baseline After median Delta
1,000 git no-op 898 ms 565 ms -37.1%
1,000 git one-file 643 ms 579 ms -9.9%
1,000 plain no-op 581 ms 553 ms -4.9%
1,000 plain one-file 601 ms 689 ms +14.7%
20,000 git no-op 13,175 ms 10,722 ms -18.6%
20,000 git one-file 10,131 ms 11,532 ms +13.8%
20,000 plain no-op 11,736 ms 10,725 ms -8.6%
20,000 plain one-file 9,563 ms 9,702 ms +1.5%

Production code is +823/-410 (net +413), and tests are +361/-18. The one-off measurement harness was intentionally not shipped after the unused-file gate; the benchmark table remains the captured evidence. The positive production delta pays for bounded cross-process memo transport, reconcile-lifetime ownership and instrumentation, stat-safe hashing, and extracting the quiescence lifecycle from the previous >700-line module.

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts size: XL maintainer Maintainer-authored PR labels Aug 10, 2026
@steipete
steipete marked this pull request as ready for review August 10, 2026 03:20
@openclaw-barnacle openclaw-barnacle Bot removed the scripts Repository scripts label Aug 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 43ad1b374b213fc0559c9ab8486130b38948fa44:

  • Focused proof: node scripts/run-vitest.mjs src/gateway/worker-environments/workspace-accepted-sync.test.ts src/gateway/worker-environments/workspace-finalize.test.ts src/gateway/worker-environments/workspace-hash-memo.test.ts src/gateway/worker-environments/workspace-sync-local.test.ts src/gateway/worker-environments/workspace-sync-scripts.test.ts src/gateway/worker-environments/workspace-sync-tunnel.test.ts src/gateway/worker-environments/workspace-sync.test.ts — 7 files, 60 tests passed.
  • Heavy changed gate: Testbox tbx_01kzmrnh41khp1begchx31dym7 exited 0. Its linked Actions wrapper was cancelled after the remote command completed, so that wrapper is not claimed as hosted green.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/31352861989 completed green, including openclaw/ci-gate; the full uncommitted autoreview and follow-up autoreview after removing the unused benchmark harness were both clean with no accepted/actionable findings.
  • Deterministic hash work fell from 5N to N remotely (80%) and 4N to N on the gateway (75%). Median wall time improved in 5/8 cases, was near-flat in 1/8, and slower in 2/8 amid 7–38% spread, so this is hash-work evidence rather than a latency guarantee.
  • No ClawSweeper Rank-up moves: were published. Known proof limitation: the benchmark uses local child processes in place of real SSH handshakes and rsync transfers.

@steipete
steipete merged commit 592bf90 into main Aug 10, 2026
132 checks passed
@steipete
steipete deleted the steipete/zealous-murdock-eae838 branch August 10, 2026 03:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
)

* perf(workers): reuse workspace hashes during reconcile

* chore(workers): drop one-off sync benchmark harness
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 size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant