Skip to content

SCM - Avoid redundant refreshes of the Repositories view for child repositories - #338592

Open
Keith Daulton (d13) wants to merge 1 commit into
microsoft:mainfrom
d13:scm-repositories-worktree-refresh-storm
Open

Keith Daulton (d13) wants to merge 1 commit into
microsoft:mainfrom
d13:scm-repositories-worktree-refresh-storm

Conversation

@d13

Copy link
Copy Markdown

Fixes #338547

When the Source Control Repositories view isn't in explorer mode (scm.repositories.explorer: false, the default), child repositories such as worktrees are nested under their parent repository row. With many worktree repositories open (for example, git.detectWorktrees: true with 50 worktrees), the view refreshes the whole tree and collapses/re-expands the parent row about twice per worktree during startup.

There are two causes in scmRepositoriesViewPane.ts:

  • updateRepository() falls through to a full refresh. For a child repository, it refreshes the parent via updateParentRepository() and then falls through to updateChildren(), a full recursive refresh of the tree.
    • In non-explorer mode, the root's children are only repositories without a parentId, so a child repository change can't change them.
    • updateChildren(parent) already re-evaluates the parent's hasChildren.
    • This change returns after refreshing the parent.
  • The historyItemRef subscription isn't gated on explorer mode. Every history item ref change triggers updateRepository(), even though outside explorer mode there are no artifact groups for a ref change to affect.
    • This change gates the subscription on explorerEnabledConfig, the same way the artifact-group subscription right above it already is.

Verification

MutationObserver on .scm-repositories-view in Insiders 1.140.0, 50 worktree repositories. The fixed versions of the two methods were applied at runtime to SCMRepositoriesViewPane.prototype before the view initialized:

DOM mutations Parent collapse/re-expand cycles
Before (2 runs) 114,308 / 114,991 99 / 99
After (2 runs) 54,522 / 53,691 1 / 1

Explorer mode (scm.repositories.explorer: true) is unchanged.

…positories

When the Repositories view is not in explorer mode, child repositories
(e.g. worktrees) are nested under their parent. updateRepository()
refreshed the parent and then fell through to a full recursive refresh
of the tree, and every history item ref change triggered another parent
refresh and expand. With many worktree repositories this caused the
parent row to collapse and re-expand about twice per worktree during
startup.

Return after refreshing the parent, and only react to history item ref
changes in explorer mode, where they affect the artifact groups.

Fixes microsoft#338547
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • src/vs/workbench/contrib/scm/browser/scmRepositoriesViewPane.ts

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

SCM Repositories view repeatedly refreshes and re-expands on startup with many worktree repositories

3 participants

Sponsor
SponsoredKunjungi sekarang
Promo