Repository navigation
Conversation
Trace2 collects Windows process ancestry synchronously before command dispatch. Each ancestor lookup restarts Process32First/Process32Next on the same snapshot, so a deep process tree repeats the enumeration work. Enumerate the snapshot once into a PID-keyed hashmap and follow parent IDs through that map. Preserve the existing ancestor order, missing-parent handling, cycle marker, and truncation limit. Release the snapshot before the in-memory walk and free the map after the walk. Temporary memory scales with process count. Snapshot creation and event writes remain synchronous. Give the internal walk an explicit start PID for deterministic Windows unit tests. Add unit tests for missing entries, unordered entries, colliding buckets, rehashes, high PIDs, cycles, and truncation. Add a functional test that checks the parent chain and compares the legacy and cmd_ancestry arrays. Add a performance test for git version with Trace2 disabled and enabled. On an ARM64 Windows host, matched local x64 builds at 5812916 show median git --version wall time of 112.2 ms before and 85.4 ms after, with Trace2 active against NUL. Both builds use identical flags, version strings, and configuration. Each result uses 80 interleaved samples. The Trace2-disabled medians remain 55.1 ms. Signed-off-by: Tyrie Vella <tyrielv@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Assisted-by: GPT-6.1 Sol
tyrielv
marked this pull request as ready for review
November 10, 2026 00:17
This branch has not been deployed
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.
Problem and Context
When Trace2 is active on Windows, Git creates a system-wide process snapshot and searches it again for each ancestor.
Repeated
Process32FirstandProcess32Nextcalls increase the synchronous startup cost of short Git commands.Changes
windows/ancestryandcmd_ancestryarrays.git versionwith Trace2 disabled and active against NUL, registered in Make and Meson.Performance
Matched local x64 builds at
581291682aduse identical compiler flags, version strings, and configuration on an ARM64 Windows host.Each cell below uses 80 randomized, interleaved samples.
git --version, Trace2 offgit --version, active Trace2 to NULgit rev-parse --git-dir, active Trace2 to NULLocal-file targets show comparable improvements.
The ancestry interval falls from 35.4 ms to 13.0 ms across 20 paired traces with identical ancestor arrays.
The system snapshot and event writes remain synchronous, so this change does not remove all Trace2 overhead.
Temporary memory scales with the snapshot process count.