Skip to content

Reuse frozen full-selection trees during assisted commit capture [8/8] - #23124

Merged
sergiou87 merged 1 commit into
developmentfrom
sergiou87-assisted-commit-performance
Nov 4, 2026
Merged

sergiou87 merged 1 commit into
developmentfrom
sergiou87-assisted-commit-performance

Conversation

@sergiou87

@sergiou87 sergiou87 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #23081; targets sergiou87-assisted-commit-architecture-docs. No separate issue is closed.

Description

Reduce the Git process startup cost of freezing whole-file selections before assisted commits. On the measured Windows ARM64 VM, capture was 13–16% faster for 12–48 wholly selected files, while the all-partial control was unchanged within noise.

  • A complete file selection already has an immutable fullTree built from the same base, selected entry and blocking deletions. Reuse that object ID instead of building the identical selected tree again: one fewer read-tree, update-index and write-tree per whole-selected file.
  • Partial selections still build their own selected trees and retain native diff certification. Native Git path discovery, per-file content/type/mode/identity checks, final HEAD/index/operation checks, cancellation, ownership, execution and rollback guards are unchanged.
  • No parent-directory shortcut, descendant-identity assumption, stale route cache or new concurrency. Tree materialization was a larger measured cost than metadata-path lookup and offered a smaller, directly provable optimization.
  • Add real-Git regressions for whole, partial and mixed selections, shared/separate directories, literal paths and unrelated staged content. Document the capture-local reuse invariant.

Measurements

Selection Windows Git calls, before → after Windows median capture, before → after Windows improvement macOS median capture, before → after
1 whole file 72 → 69 2964.0 → 2858.6 ms 3.6% 541 → 494 ms
12 whole, shared directory 248 → 212 9923.3 → 8529.3 ms 14.0% 1866 → 1686 ms
12 whole, separate directories 248 → 212 9893.0 → 8578.3 ms 13.3% 1881 → 1734 ms
48 whole, shared directory 824 → 680 33305.8 → 27856.5 ms 16.4% 6943 → 5721 ms
12 partial 260 → 260 10182.0 → 10225.8 ms -0.4% (noise) 2206 → 2001 ms
6 whole + 6 partial 254 → 236 9864.0 → 9286.6 ms 5.9% 2068 → 1898 ms

Windows measurements come from a supplied native Windows 11 ARM64 report: Parallels VM, 6 vCPUs, 10 GiB RAM, local NTFS, Defender enabled, native Node 24.22.1 and Desktop-bundled ARM64 Git 2.56.0.windows.4. One warmup plus five measured rounds per variant, alternating baseline/optimized order, all scenarios serial, no concurrent regression suite or build. These are capture-only wall times: harness process startup, fixture/request setup and disposal are outside the interval; Git subprocess startup is inside it. This is one ARM64 VM workload, not an x64 or population-wide performance claim.

macOS measurements used Node 24.22.1 and bundled Git 2.56.0 on macOS 26.7.2 arm64: one warmup plus five sequential samples per variant, non-interleaved before/after runs on a shared machine. These timings are observational; the unchanged all-partial control also varied. macOS Git totals are exactly two below every Windows cell because the Windows fixture commits .gitattributes; freezing it adds one hash-object and one update-index, not Windows-specific production work.

Only the expected three materialization operations changed in count per whole-selected file. The Windows report records all 72 captures preserving exact selected trees/blob manifests, HEAD and HEAD-file bytes, index bytes, working-file bytes and owned disposal; unrelated staged and working content never entered the selected tree. Local macOS raw traces and the supplied Windows report were inspected; the Windows raw JSON/log files remain on the VM and are not attached to this PR.

Benchmarks compare 4f843bc0d89a2060c1f93a1803fef257d5c529b7 with the original optimization 6d90f1ad2c606897cd41af6d901ebbd1b1108850. The optimization was then rebased onto stack parent 65bcfc973dda124c475b3b8ed091fcc7aa1bdf9a; git range-diff reports an identical patch, and the measured assisted-commit production files, regression test and fixture helper are byte-identical after rebase. Benchmarks were not rerun on the rebased commit.

Validation

Current rebased commit: 6eb692dc9ba8f700097c171da6cdc51ed548e165.

  • node vendor/yarn-1.21.1.js test app/test/unit/git/assisted-commit-snapshot-test.ts — passed, 3/3 on the rebased commit. Before the optimization, whole/mixed count assertions failed; the all-partial case already passed.
  • GIT_CONFIG_PARAMETERS="'safe.bareRepository=all'" node vendor/yarn-1.21.1.js test --test-concurrency=4 — passed, 3566 passed / 2 skipped / 0 failed on the rebased commit.
  • node vendor/yarn-1.21.1.js lint:fix — passed on the rebased commit; no working-tree edits.
  • node vendor/yarn-1.21.1.js lint — passed on the rebased commit.
  • node vendor/yarn-1.21.1.js tsc --noEmit — passed on the rebased commit.
  • node vendor/yarn-1.21.1.js exec markdownlint -- docs/technical/assisted-commit-transactions.md --config .markdownlint.js --rules .markdownlint-rules.js — passed.
  • git diff --check HEAD^ HEAD — passed.

The full-suite bare-repository override is process-local. The initial macOS run on the original optimization had four unrelated push/bare-discovery failures caused by an injected safe.bareRepository=explicit; all four also failed with the original production source restored. The previous full run passed with the test-local override, without changing production policy or any Git configuration file.

The supplied Windows report ran relevant transaction/integration, planning, selected-fence, cleanup, completion and real-hook suites: baseline 153 passed / 3 failed / 15 skipped; optimized 156 passed / the same 3 failed / 15 skipped, including the three added tree-reuse tests. The three existing hook failures reproduced independently as exit 127, sleep: command not found. Supplemental unchanged focused reruns passed 3/3 on each variant with a process-local Node-backed sleep helper; that helper was not used for any performance measurement. These supplemental results do not turn the original failing suite commands into passing runs. Exact Windows per-suite commands and raw logs are listed in the VM report artifacts but are not attached here.

No full Windows unit suite, product build, live-model test or UI E2E run was performed.

Stack

Existing ordered stack members are preserved, including the five already-merged layers. This PR adds the next layer above #23081.

  1. #22971 — Repository-scoped assisted commit UX (merged)
  2. #22976 — Selected snapshots and validated Git transactions (merged)
  3. #22977 — Constrained Copilot-assisted commit planning (merged)
  4. #22986 — Awaited local runs and recovery (merged)
  5. #22991 — Optional push and push-only retry (merged)
  6. #23079 — Shared Copilot lifecycle helpers
  7. #23081 — Assisted commit architecture documentation
  8. #23124 — Reuse frozen full-selection trees during assisted commit capture (this PR)

Team-authored review

Evidence: Measurements and validation above. No visual artifact is applicable to this backend-only change.

Review path: Lightweight review. The author has assessed the change and evidence.

Screenshots

N/A — backend-only optimization; no UI changes.

Release notes

Notes: no-notes

@sergiou87
sergiou87 added this pull request to stack #22992 November 4, 2026 16:09
@sergiou87
sergiou87 marked this pull request as ready for review November 4, 2026 16:55
@sergiou87
sergiou87 requested a review from a team as a code owner November 4, 2026 16:55
@sergiou87
sergiou87 requested review from babakks and a balanced review from Copilot November 4, 2026 16:55

@tidy-dev tidy-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

tidy-dev
tidy-dev previously approved these changes Nov 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the change to reuse frozen full-selection trees during assisted commit capture.

No open issues 🎉

What changed in this PR

This follow-up to #23081 reduces Git subprocess overhead during assisted commit capture by reusing frozen full-selection trees, while preserving partial-selection handling and existing safety checks.

Changes:

  • Avoid three redundant Git operations per wholly selected file by reusing its immutable fullTree.
  • Add real-Git regression tests for whole, partial and mixed selections, including literal paths and unrelated staged content.
  • Document the capture-local reuse invariant and unchanged validation boundaries.
File Description
docs/​technical/​assisted-commit-transactions.md Documents tree reuse and preserved safety checks.
app/​test/​unit/​git/​assisted-commit-snapshot-test.ts Verifies operation counts, selected content and repository-state preservation.
app/​src/​lib/​git/​assisted-commit/​snapshot.ts Reuses fullTree for complete selections; retains separate materialization for partial selections.

Review effort: Balanced

Base automatically changed from sergiou87-assisted-commit-architecture-docs to development November 4, 2026 17:59
@sergiou87
sergiou87 dismissed tidy-dev’s stale review November 4, 2026 17:59

The merge-base changed after approval.

Complete selections already have an immutable per-file full tree with the same base, entry and blocking deletions as their selected tree. Reuse that object ID instead of repeating read-tree, update-index and write-tree for every fully selected path. Keep partial materialization, native diff certification and all final acceptance fences unchanged.

Add real-Git command-count and selection-content regressions for whole, partial and mixed selections across shared and distinct directories, literal paths and unrelated staged content. Document the capture-local reuse invariant.

A representative 48-file whole selection now launches 678 Git processes instead of 822. Five warmed macOS captures had median wall time 5.72s versus 6.94s; these shared-machine observations are not native Windows measurements.
@sergiou87
sergiou87 force-pushed the sergiou87-assisted-commit-performance branch from 6eb692d to 70ab46c Compare November 4, 2026 18:00
@sergiou87
sergiou87 enabled stacked auto-merge November 4, 2026 18:21
@sergiou87
sergiou87 merged commit 5c43eb4 into development Nov 4, 2026
9 checks passed
@sergiou87
sergiou87 deleted the sergiou87-assisted-commit-performance branch November 4, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants