Skip to content

perf(gui): coalesce diff refresh after staging - #49

Open
HiFiveJazz wants to merge 1 commit into
Blankeos:mainfrom
HiFiveJazz:perf/coalesce-stage-diff-refresh
Open

HiFiveJazz wants to merge 1 commit into
Blankeos:mainfrom
HiFiveJazz:perf/coalesce-stage-diff-refresh

Conversation

@HiFiveJazz

@HiFiveJazz HiFiveJazz commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

This PR avoids eagerly refreshing the diff immediately after optimistic stage/unstage updates.

The existing stage/unstage flow already does a pretty good job of doing status-only refresh after the background Git operation completes, and that refresh schedules a diff update using authoritative repository state. However, setting needs_diff_refresh before the Git operation completes causes the same mutable diff to be generated twice, which is unnecessary

This removes those three eager diff invalidations for:

  • individual file stage/unstage
  • directory stage/unstage
  • stage-all/unstage-all

The optimistic file-status update remains unchanged, so staging still updates the file list immediately.

Performance

Measured with strace -f -e trace=execve, with auto-refresh and auto-fetch disabled.

Stage-all + unstage-all:

  • Before: 48 Git subprocesses
  • After: 44 Git subprocesses
  • Reduction: 8.3%

Single-file stage + unstage:

  • Before: 44 Git subprocesses
  • After: 42 Git subprocesses
  • Reduction: 4.5%

The removed subprocesses are the redundant diff previews issued before the authoritative status refresh. The later diff refresh after git status --porcelain -uall remains. I tested this using cargo test and saw no regressions.

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.

1 participant