Skip to content

perf(gateway): share pending staged workspace manifest reads - #183128

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-staged-manifest-inflight-20261025
Oct 25, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-staged-manifest-inflight-20261025

Conversation

@steipete

@steipete steipete commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Concurrent readers of the same staged workspace result each submit a complete manifest load. Forking one source workspace into distinct sessions is one path that permits this overlap: the target sessions have independent owners, while both read the same source checkpoint.

Change

Join matching pending staged-manifest reads at the existing result-ref owner. Identity includes the complete root/ref/build-cache input, current directory, a digest of the complete captured environment, and the exact cancellation signal. Different requests remain independent. Worker-context calls continue through their existing host-exchange owner.

The ref owner invalidates the pending lookup before and after its writes, including failed writes. Already admitted readers retain their outcome; later readers cannot join a pre-mutation result, and old settlement cannot evict a newer operation. Success and failure both remove entries. There is no completed-result cache or extra Git lookup.

This is separate from #183087 and does not change its two-await tree-input fix. It addresses staged-result read overlap; no reduction of recovery journal memory or of the previously observed 215 MiB tree-input holder is claimed.

Evidence

The regression holds the real worker at Git I/O while interleaving ten staged reads. Six distinct identities cover differing root, ref, build-cache inputs, environment, and signal; repeated identical calls arrive between them.

Work count Baseline Candidate
Physical cat-file commit reads for ten overlapping callers 10 6
Extra read after the previous calls settle 1 1

The first assertion fails on the base with expected 10 to be 6 and passes with the fix. Additional regressions prove deletion during a held read, conditional cleanup after old settlement, cancellation isolation, and retry after failure. Independent validation of staged output, byte authentication, linked-worktree ref ordering, and Git history remains covered by the existing tests.

Validation: the initial 26-test run passed across workspace-result-staging.reads.test.ts, workspace-result-staging.concurrent.test.ts, workspace-result-ref-mutation.test.ts, and workspace-result-history.test.ts (77.78 seconds Vitest; 97.99 seconds including wrapper and cold artifact preparation). The test-only follow-up at 5dd6eb3d68de releases the old read before waiting for the next worker, avoiding a single-worker test deadlock. All 16 tests in the changed reads file passed again in 50.83 seconds, including the mutation regression with both one and three compute workers (561 and 598 ms). Together with the unchanged 11 sibling tests from the earlier run, this covers 27 distinct tests. Scoped core oxlint (--tsconfig config/tsconfig/oxlint.core.json), gateway-other test typecheck (test/tsconfig/tsconfig.core.test.gateway-other.json), changed-file oxfmt, export-name collision guard, and git diff --check passed; affected gates were rerun for the follow-up. Fresh independent autoreviews of the production change and test follow-up found no actionable P0–P2 findings. Final head 5dd6eb3d68de72641506b2bc2fdf2357c785dbcf is fully green: 66 passing checks, 56 skipped, no pending or failed checks. Both the CI aggregate and maintainer aggregate passed. The completed exact-head review reports no findings. No merge was performed; the lead owns landing.

Production delta: +57 lines. The added owner state is needed to eliminate duplicate work while preserving cancellation domains and mutable-ref invalidation; it retains only unfinished promises and releases each on settlement. Test delta: +166 lines. No schema, public configuration, dependency, or timeout policy changes.

Join identical staged-result reads while their worker operation remains pending. Keep independent inputs and cancellation domains separate, and invalidate join admission around result-ref mutations so later readers observe published or deleted refs.
@clawsweeper

clawsweeper Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T02:07:42.311108Z 5dd6eb3 New commits
ℹ️ 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.

@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. labels Oct 25, 2026
@steipete
steipete merged commit 30fe1d6 into main Oct 25, 2026
139 of 141 checks passed
@steipete
steipete deleted the steipete/perf-staged-manifest-inflight-20261025 branch October 25, 2026 02:22
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…w#183128)

* perf(gateway): share pending staged workspace manifest reads

Join identical staged-result reads while their worker operation remains pending. Keep independent inputs and cancellation domains separate, and invalidate join admission around result-ref mutations so later readers observe published or deleted refs.

* test(gateway): support single-worker staged read regression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant