Repository navigation
perf(gui): coalesce diff refresh after staging - #49
Conversation
|
Confidence: 5/5Ran SummaryUpdate: I pushed Thanks @HiFiveJazz, nice and focused. Removing the eager Mapflowchart LR
A[controller/files.rs toggle_stage / toggle_stage_all] --> B[gui/mod.rs enqueue_stage_then_refresh]
B --> C[git stage/unstage thread]
C --> D[refresh_files_status_only]
D --> E[receive_files_refresh]
E --> F[needs_diff_refresh = true]
F --> G[begin_diff_request]
Regressions
MigrationsNone. No config, keybinding, or format change. Before merging
|
Blankeos
left a comment
There was a problem hiding this comment.
Approved after review and checks (see the pr-review comment).
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_refreshbefore the Git operation completes causes the same mutable diff to be generated twice, which is unnecessaryThis removes those three eager diff invalidations for:
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:
Single-file stage + unstage:
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 testand saw no regressions.