Skip to content

Worktree lookup runs git on the main thread while labels are drawn #647

Closed

Description

@goneng

-worktreePathsByRefName runs git worktree list --porcelain lazily, and the
cache is cleared on every refs reload. The next caller repopulates it, and that
caller is often drawing: PBGitRevisionCell -colorForRef: from
-drawLabelAtIndex:, and the sidebar cell from
-outlineView:viewForTableColumn:item:. Both are on the main thread, and
PBTask waits for the process.

Measured here, 5 worktrees, warm cache, local SSD:

git worktree list --porcelain: median 9.4ms  min 9.0ms  max 9.9ms

So it is one git process per refs reload, not per row, and under a frame at
60fps in normal conditions. It matters where git is slow to start or the
repository is on a network filesystem, where the first label drawn after each
reload stalls the UI for however long the task takes.

Populating the snapshot off the main thread and having the drawing paths read
the finished result would remove the stall.

Raised by Copilot on #633 and confirmed while reviewing it. Filed separately
rather than fixed there, since the drawing paths predate that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions