Reduce Git configuration discovery overhead on Windows - #2964
Draft
Sebastian Thiel (Byron) wants to merge 2 commits into
Draft
Reduce Git configuration discovery overhead on Windows#2964Sebastian Thiel (Byron) wants to merge 2 commits into
Sebastian Thiel (Byron) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 04bef3fb94
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "Codex (@codex) address that feedback".
Sebastian Thiel (Byron)
force-pushed
the
error-conversion-review
branch
from
September 2, 2026 07:40
e8d5a09 to
541f097
Compare
Sebastian Thiel (Byron)
marked this pull request as draft
September 2, 2026 08:19
…s and add `env::system_config()` <!-- agent --> On Windows, enabling both Git-installation and system configuration could launch Git twice: once to inspect configuration origins and once for `--exec-path`. This is especially visible where process startup costs about 50 ms. Request `--show-scope` alongside `--show-origin`, parse both the highest-precedence file and the first distinct system-scoped file, and cache the pair. Keeping the paths distinct matters when Git for Windows reports its installation file before the ProgramData system file. `gix-config` now consumes the direct system-config path, so both sources share one probe. Fall back to an origin-only query when Git predates `--show-scope`, which was introduced in Git 2.26. Keep system-config environment overrides authoritative by hiding paths obtained through ambient configuration when those overrides are present. Assisted-by: GPT 5.6 Co-authored-by: GPT 5.6 <codex@openai.com>
Callers that already know the Git-installation and system configuration files can now provide both paths through `gix::open::Options`. The paths flow through repository opening and standalone configuration loading, while the existing source permissions continue to decide whether each file is read. Using both presets bypasses automatic path discovery entirely. A dedicated integration test loads distinct values from both files and uses `GIT_TRACE` to verify that no Git process was launched. Validation: `cargo test -p gix --test open_options`; `cargo test -p gix --lib open::tests::size_of_options`; `cargo test -p gix --doc`; `cargo check -p gix --all-targets`; `cargo check -p gix --no-default-features --features sha1`; `cargo clippy -p gix --test open_options -- -D warnings`; `cargo fmt --all -- --check`; `git diff --check`. # 04bef3f fix(gix): honor no-system config with preset paths fix(gix): honor no-system config with preset paths Preset paths replace path discovery, but must not bypass Git's explicit `GIT_CONFIG_NOSYSTEM` switch. Read the permitted environment value once before selecting Git-installation and system sources, preserving the behavior already implemented by `gix_config::Source::storage_location()`. Extend the preset-path integration test to prove both files remain unloaded when the switch is enabled and that Git is still never launched. Validation: `cargo test -p gix --test open_options`; `cargo clippy -p gix --test open_options -- -D warnings`; `cargo check -p gix --all-targets`; `cargo fmt --all -- --check`; `git diff --check`.
Sebastian Thiel (Byron)
force-pushed
the
error-conversion-review
branch
from
September 2, 2026 09:38
541f097 to
e33114f
Compare
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.
Tasks
This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.
Everything below this line was generated by
Codex.Created by Codex on behalf of Byron. Byron will review before this is ready to merge.
Summary
gix::open::Options, which avoids launching Git entirely when both are supplied.GIT_CONFIG_NOSYSTEMsemantics for preset paths.Reported issue
Current Behavior
After upgrading from 1.17.1 -> 1.26.0 (yes, I hadn't upgraded in a long time), there was a noticeable slowdown in the git prompt speed for small repos. In my prompt, I'm only including
git_branch/git_commit/git_state/git_status.Before, zipping around smaller repo's felt basically instant. Now it takes ~150ms for the prompt to render which is slow enough for my eyes to catch and be grating.
Expected Behavior
For the prompt in smaller repo's, it should be no slower than manually running
git status.Additional context/Screenshots
I manually added
instant.elapsed()calls around the code and found that of the ~150ms, most was not actually spent performinggit status. Rather, ~100ms was taken for this singular line: https://github.com/starship/starship/blob/cc763c5557a235530ff00c8917169bb77aac1e24/src/context/mod.rs#L369If I shrink my prompt just to git_branch, this ~100ms now takes up basically all the time.
If I do a targeted revert of starship/starship@daf8d93#diff-d6346fd7d17270b1282142aeeda9c4bc2b7d8fd0f37b24a1c871a9257f0ed0aa

Specifically, only these 4 lines:
Then, that ~100ms turns to single digit milliseconds!
Possible Solution
I'm not familiar enough with the code to know why it's necessary for correctness to have that change. Given the context of the PR that introduced it, maybe those fields could be set back to false if
use_git_executableis true andgit_metricsis not enabled?Sebastian Thiel (@Byron) would love to get your insight :)
Environment
Relevant Shell Configuration
Starship Configuration
Thanks for chiming in David, and thanks so much for your help with all of this Brandon Dong (@brandondong)!
I am also interested in this, maybe there is a regression that disguised itself, as that code definitely changed. However, from my testing on macOS, it got faster.
So how can we learn what's going on here? Could you try to turn
git_binaryoff, all the other flags off as well, and see if there is one of them adding disproportional amounts of time? Maybe they are all the same amount of time as well, which would also be good to know. My guess is of course that this is related to IO which you say is fast, so the other guess is that the binary under test isn't a release build (but that's easily discarded as unlikely). So I am out of guesses, without IO and CPU profiling.I tested with both debug and release builds, no difference.
It turns out it's the
systemflag that is adding all the 50ms time. I don't have gix cloned to be able to add timing logs but just looking at the source code, I think it'sNeither environment variable is set on my system. If I set
GIT_CONFIG_NOSYSTEMto "true" orGIT_CONFIG_SYSTEMto some dummy path, the 50ms overhead is eliminated. Same if I run from the git bash app but not git bash through Windows Terminal.Commits
51a9dbd802— query both configuration paths with one Git process.be1698c200— expose both preset paths throughgix::open::Optionsand prove they avoid Git execution.04bef3fb94— preserveGIT_CONFIG_NOSYSTEMfor preset paths.e8d5a09289— retain a distinct system path when Git reports multiple system-scoped files.Validation
cargo test -p gix-pathcargo test -p gix-configcargo check -p gix-path --tests --target aarch64-pc-windows-msvccargo clippy -p gix-path --all-targets -- -D warningscargo test -p gix --test open_optionscargo test -p gix --lib open::tests::size_of_optionscargo test -p gix --doccargo check -p gix --all-targetscargo check -p gix --no-default-features --features sha1cargo clippy -p gix --test open_options -- -D warningscargo fmt --all -- --checkgit diff --check