Skip to content

perf(sessions): batch untracked diffs and reuse unchanged reads - #177195

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-diff-untracked-no-index-fanout-20260919
Oct 19, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-diff-untracked-no-index-fanout-20260919

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session diff polling starts a separate Git process for every readable untracked file, even for a summary-only request. With U readable untracked files, the measured scope=all path takes 5+U commands for counts and 6+U for full previews; tracked changes are already batched. A 100-untracked-file fixture (99 readable files plus one symlink) therefore takes 104/105 commands.

User Impact

Diff summaries and full previews use 8 and 9 Git commands respectively on that fixture, independent of file count. Eligible unchanged checkouts reuse the result with zero Git commands. Native patch bytes, binary handling, symlink/hardlink restrictions, ignored files, file caps, and preview budgets remain intact. No configuration or migration is required.

Why This Change Was Made

An empty private index with intent-to-add entries lets Git calculate all untracked changes in one call while preserving attributes and content conversions. Starting empty matches the former no-index behavior, which does not load tracked index-backed attributes. Its object writes are private, the native alternates file preserves access to original and inherited object stores, and split-index writes are disabled so the original index and its backing files stay untouched. Full reads retain a bounded prefix for each patch, so a large file cannot hide later previews or force duplicate conversions.

The existing Git read cache owns reuse and lifecycle. A bounded filesystem revision observes the checkout, index, refs, ignore/attribute/config metadata, and relevant environment. Git reports its actual system config/attribute paths once per worker and installation/environment identity (two cold discovery commands); binary replacement, PATH or environment changes retire that discovery. Unsupported layouts (including trees exceeding 10,000 metadata entries, Windows, nested repositories, external filters/config includes, indirect Git metadata, or older Git without path discovery) keep the previous refresh behavior. Required-filter failures retain partial results through error-only per-file retries; only failed batches can fan out.

The old successful per-file no-index path is removed. Runtime code grows by 392 lines because byte fidelity requires native Git conversion and bounded patch capture, while externally edited checkouts need a complete bounded invalidation check. The reusable benchmark adds 241 lines; regression tests add 221 net lines. No new cache owner, filesystem watcher, or dependency is introduced.

Evidence

Acceptance recorded before measurement: 100 untracked files plus three tracked changes; summary/full worker reads and unchanged read-owner polls; two concurrent baseline/candidate pairs with swapped 16-core allocations. Require O(1) commands, identical normalized response hashes, and paired p50/p99 improvement or no regression beyond noise. Unchanged eligible checkouts must issue zero Git commands after the former summary TTL too.

Final concurrent A/B results (CPU halves swapped in pair 2):

All durations are milliseconds. Differences are B minus A within the same concurrent pair.

Scenario Pair n Git A→B p50 A→B Δ p50 p99 A→B Δ p99
Changed summary (worker) 1 40 104→8 509.27→46.36 -462.91 550.67→57.39 -493.28
Changed summary (worker) 2 40 104→8 485.31→43.94 -441.37 524.03→50.37 -473.66
Changed full (worker) 1 40 105→9 543.47→52.74 -490.73 587.47→61.59 -525.88
Changed full (worker) 2 40 105→9 524.69→52.68 -472.00 596.11→59.91 -536.20
Unchanged full (read owner) 1 40 105→0 529.34→0.76 -528.58 573.03→2.68 -570.35
Unchanged full (read owner) 2 40 105→0 528.11→0.76 -527.35 556.47→2.66 -553.81
Unchanged summary >10s (read owner) 1 8 104→0 501.99→2.75 -499.24 577.68→3.71 -573.97
Unchanged summary >10s (read owner) 2 8 104→0 482.88→2.84 -480.04 504.59→2.94 -501.66

256/256 measured response SHA-256 comparisons matched; only each fixture’s absolute root field was removed. All file metadata and patch bytes were preserved. This includes binary, large, empty, symlink, and ignored-file behavior.

Fixture: 100 untracked paths (99 eligible regular files plus one symlink), three changed tracked files, and one excluded ignored file. Baseline: 73f67dc. Git 2.53.0, Node v26.8.2.

All pairs ran concurrently under the shared exclusive measurement lock, A on CPUs 96–111 and B on 112–127 in pair 1, swapped in pair 2. Preparation used CPUs 64–95. Outside load was recorded with per-scenario mpstat logs; paired deltas above determine the result. Warmup is excluded; trace2 command-count overhead is included on both sides. No Gateway, network client, model, or production data was used. These measure the real Git worker/read owners, not end-to-end RPC latency.

The cache pairs use the final revision owner and were retained across the subsequent cold untracked-collection repair; the measured cache-hit path was unchanged. Worker pairs were rerun after that repair. Each source state was recorded in a manifest.

Final source manifest (309 files, verified remotely): bf7e8531423c2acf1eebc74c9471877eb5b13da82bb0d71ad46d851b81272193.
Cache-pair source manifest: 4bc1f6a695ca55febaafd554f5ded25ea8309cd607a74caafe1f51c75f2b9f4f.

For eight samples, the reported p99 is the observed maximum. The committed driver is scripts/perf/checkout-diff-measure.ts; its README documents fixture creation, commands, and interpretation.

Validation: the complete session-diff file passes all 36 cases; all 14 read-cache tests pass, including byte comparisons for binary/large/empty/symlink/ignored fixtures, sparse/split-index preservation, failed required filters, cache reuse and edit/index/ignore invalidation. The custom-installation cache regression is red on the prior hardcoded-path candidate: a newly created system config left an ignored file visible. The count regression is red on the base: 49 full / 48 summary commands against cold bounds of 11 / 10 (including two one-time installation probes). One pnpm tsgo:core run passed on the earlier candidate; final-head type validation is left to PR CI under the local compute limit. Export collision guard and both import-closure files passed (22 tests). Changed-file format/lint passed; independent Codex review is clean at P0–P2; PR CI owns broader validation. No Testbox/Crabbox lease was used.

CI follow-up: the first run caught three test cleanup callbacks returning VitestUtils instead of void. Environment restoration now belongs to the existing afterEach, removing the duplicate callbacks. The entire 36-case session-diff file and changed-file lint pass after the repair; an independent review of the test-only delta is clean. Production code and benchmark inputs are unchanged.

Final validation: CI run 39231026877 passed on e577d6182c5233ac1ec23bc2ea8006b25da9fce7, including all production/test type checks and selected test/check jobs. Both required CI gates passed before the exact-head squash merge.

@clawsweeper

clawsweeper Bot commented Oct 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 in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 19, 2026 09:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T09:39:33.555763Z e577d61 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts size: XL labels Oct 19, 2026
Replace per-file no-index processes with a private intent-to-add index and bounded patch capture. Preserve native conversion, partial results, and checkout index state. Reuse unchanged results through the existing read cache with bounded filesystem revision checks and installation-aware Git dependencies.
@steipete
steipete force-pushed the steipete/perf-micro-diff-untracked-no-index-fanout-20260919 branch from ef14c7f to e577d61 Compare October 19, 2026 09:33
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 19, 2026
@steipete
steipete merged commit a413e73 into main Oct 19, 2026
130 checks passed
@steipete
steipete deleted the steipete/perf-micro-diff-untracked-no-index-fanout-20260919 branch October 19, 2026 09:47
steipete added a commit that referenced this pull request Oct 19, 2026
Model the documented standalone benchmark from #177195 as a production Knip entry. Remove the unused TTS test-support alias left by #177175; production Talk continues to use the canonical speech-text fallback directly.

Validated 58 focused tests, CLI help, targeted typecheck and lint, formatting, and P2 review. All three deadcode scans ran: unused files are clean; full-tree dependencies and exports retain only the unrelated BroadcastFrame type introduced by #177219.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…claw#177195)

* perf(sessions): batch untracked diffs and reuse unchanged reads

Replace per-file no-index processes with a private intent-to-add index and bounded patch capture. Preserve native conversion, partial results, and checkout index state. Reuse unchanged results through the existing read cache with bounded filesystem revision checks and installation-aware Git dependencies.

* test(sessions): restore stubbed environment in shared cleanup
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
Model the documented standalone benchmark from openclaw#177195 as a production Knip entry. Remove the unused TTS test-support alias left by openclaw#177175; production Talk continues to use the canonical speech-text fallback directly.

Validated 58 focused tests, CLI help, targeted typecheck and lint, formatting, and P2 review. All three deadcode scans ran: unused files are clean; full-tree dependencies and exports retain only the unrelated BroadcastFrame type introduced by openclaw#177219.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:feature Preliminary submission classification; full source review pending. gateway Gateway runtime scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant