Repository navigation
Avoid unnecessary --numstat diff for incoming changes decorations - #339008
Merged
Ladislau Szomoru (lszomoru) merged 1 commit intoOct 6, 2026
Merged
Ladislau Szomoru (lszomoru) merged 1 commit into
Ladislau Szomoru (lszomoru) merged 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused API substitution preserves the required Change[] data while eliminating unused statistics computation.
Review effort: Balanced
Findings: None
What changed in this PR
Replaces the stats-producing Git diff with a cheaper name/status diff for incoming-change decorations.
Changes:
- Uses
diffBetween()instead ofdiffBetweenWithStats(). - Avoids unnecessary
--numstatblob processing.
| File | Description |
|---|---|
extensions/git/src/decorationProvider.ts |
Retrieves only the change metadata required for decoration badges. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Tyrie Vella (tyrielv)
force-pushed
the
fix/incoming-changes-decoration-numstat
branch
from
September 30, 2026 22:52
1b884d1 to
a354b79
Compare
Tyrie Vella (tyrielv)
marked this pull request as ready for review
September 30, 2026 22:52
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Ladislau Szomoru (@lszomoru)Matched files:
|
GitIncomingChangesFileDecorationProvider.getIncomingChanges() called repository.diffBetweenWithStats(), which runs `git diff --numstat` and computes insertions/deletions for every changed file. The only caller, collectIncomingChangesFileDecorations(), only reads change.status/change.uri/change.originalUri to pick a badge glyph and never reads the stats. This method runs automatically, with no debounce, whenever the current or remote history item ref changes - including every git.autofetch tick (default every 180s) for any repo with an upstream. On a large repository backed by a partial-clone or virtualized-filesystem remote, --numstat forces git to read full blob content for every added/modified/deleted path in the diff range, and each read can be a lazy network fetch rather than a local disk read. Switch to diffBetween(), which already exists and returns exactly the Change[] shape this caller needs, without --numstat or --find-renames.
Tyrie Vella (tyrielv)
force-pushed
the
fix/incoming-changes-decoration-numstat
branch
from
September 30, 2026 22:57
a354b79 to
3d4d603
Compare
Ladislau Szomoru (lszomoru)
approved these changes
Oct 6, 2026
Ladislau Szomoru (lszomoru)
enabled auto-merge (squash)
October 6, 2026 18:53
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 6, 2026
Aaron Munger (amunger)
approved these changes
Oct 6, 2026
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
GitIncomingChangesFileDecorationProvider.getIncomingChanges()(inextensions/git/src/decorationProvider.ts) computes the "Incoming Changes"file badges by calling
repository.diffBetweenWithStats(). That method runs:The only consumer of the result,
collectIncomingChangesFileDecorations(),reads only
change.status,change.uri, andchange.originalUrito pick abadge glyph (added/deleted/renamed/modified). It never reads the
insertions/deletionsstats that--numstatcomputes, so that work isalways discarded.
This code path runs automatically and without debounce whenever
historyProvider.onDidChangeCurrentHistoryItemRefsfires, which happens onevery git write operation and on every VS Code built-in auto-fetch tick
(
git.autofetch, default every 180s) for any repository whose checked-outbranch has an upstream.
On a large repository backed by a partial-clone or virtualized-filesystem
remote (e.g. GVFS/VFS for Git),
--numstatforces git to read full blobcontent for every added/modified/deleted path in the diff range, and each of
those reads is a lazy network fetch rather than a local disk read. We
measured this directly: on such a repository, incoming ranges touching
several thousand files took 60-200+ seconds and pulled thousands of objects
over the network, purely to compute stats that are then thrown away. Because
the handler isn't debounced, repeated ref-change events can also stack up
multiple concurrent invocations of this work.
Changes
getIncomingChanges()now callsrepository.diffBetween()instead ofrepository.diffBetweenWithStats().diffBetween()already exists as asibling method, already returns exactly the
Change[]shape this callerneeds (status + uri + originalUri), and builds a cheaper diff with no
--numstatand no explicit--find-renamesflag.git.similarityThreshold,rename detection) are touched;
diffBetweenWithStats()remains availableand unchanged for its other callers.
Known gaps and deliberate decisions
git config —
diffBetween()does not pass--find-renames=<git.similarityThreshold>%the waydiffBetweenWithStats()did, so incoming-change rename detection now falls back to git's own
diff.renamesdefault instead of the user's configured threshold. Withdefault git and VS Code settings (
diff.renameson, 50% threshold on bothsides) the output is identical either way. Only a repository with
diff.renamesexplicitly disabled, or agit.similarityThresholdfar from50%, would see a renamed file decorated as separate added (
↓A) and deleted(
↓D) badges instead of a single renamed (↓R) badge. The set of filesdecorated as "incoming changes" is unaffected either way; only the glyph
choice for renames can differ, and only for non-default configs. This
tradeoff was evaluated and accepted to avoid reintroducing the
--numstat/blob-hydration cost this PR removes. No follow-up is planned; afull fix would mean plumbing
similarityThresholdintodiffBetween(),which is a separate, larger change.