Repository navigation
Conversation
Collaborator
Author
|
Closing: the saving is a few milliseconds of in-memory compares, only on discards of hundreds to thousands of files, next to git restore/clean subprocesses that cost far more, and the PR measured no latency. It adds stateful budget and index switching to the tracked/untracked partition, where a mistake would delete files instead of restoring them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bulk discard repeatedly searches the same tracked-path list while deciding which selections go to
git restoreand which go to safe untracked cleanup. With 1,000 individually selected tracked files, that partition performs 500,500 comparisons before the native write. This change reuses the existing operation-local normalized cache and switches repeated expensive scans to a sorted index.The matcher stays lazy for small selections and cheap first-descendant matches. For multiple requests and at least two tracked entries, it budgets
N × ceil(log2(N))scan comparisons. A successful match returns immediately. Only a nonmatch with both remaining evidence and a future request builds the index: it fills the existing cache, sorts that same array once, and uses separate lower bounds for exact paths and slash-delimited descendants. A completely exhausted miss and the last request do not trigger construction. There is no second normalized array, Set, persistent cache, subprocess or wire change.Measured work
These are deterministic counts from executed source, not timing or heap measurements. The production-shaped mixed case contains 700 selected tracked entries and 300 untracked selections, matching the existing selected
ls-filesoutput.Sort population is measured; the engine's sorting comparisons, scratch allocations, CPU, latency and retained heap are unmeasured. An earlier pure mixed benchmark included unselected tracked evidence; it remains explicitly labeled API-only and is excluded from the production mixed count above.
Correctness and validation
ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --base=0e9ba2167b8cd16bffddce50c908bf0400da10e2 --maxWorkers=2: all 20 checks pass in 1,158.5 seconds; 1,228 affected test files and 14,166 tests pass (7 expected failures and 96 skips). Actual worker temp paths used the short task-owned cache root. All 400 observed process identities exited and the task temp root is empty.This is synchronous, operation-local host work. Existing Git routing, chunked command admission, invalidation and cancellation ownership remain unchanged. Desktop, web/mobile and folder workspaces share the existing API; there is no new git-worktree assumption. Native proof ran on Linux. Live macOS, Windows, WSL, SSH and mobile execution, rendered UI, whole-app responsiveness and heap behavior were not measured.
Integration before merge
Coordinate with #27757 (POSIX/Windows tracked-path normalization) and its related WSL input work #28862. This draft deliberately preserves its parent's normalization policy; #27757 changes the same module/public API and the bulk-discard caller. Compose or restack the changes and retain both sets of controls before merge. This PR does not implement or supersede that path-policy correction.
Source is pinned to parent
0e9ba2167b8cd16bffddce50c908bf0400da10e2, candidate treefd71c534d06cc1581aa5dad5c1b3390aedcb756e. Detailed raw evidence is retained locally intracked-partition-index-actual-v2,tracked-partition-index-independent-git-execandtracked-partition-index-gatepackets. The two source/test files are the complete product delta.