Repository navigation
fix(git): avoid repeated full repository scans - #353
Merged
Merged
Conversation
Let status scans finish, coalesce pending refreshes, and schedule idle polls after a cooldown based on scan duration. Preserve cached status across failures and cancel pending work on shutdown or repository changes. Skip diff statistics for empty tracked sections so opening a clean dashboard does not launch another full worktree scan.
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.
The Git plugin refreshed status every five seconds by cancelling any scan still running and starting another. In large repositories, where a scan can take much longer than five seconds, that can keep CPU usage high and prevent status from completing even with the dashboard closed. Opening a clean dashboard also launched a full diff-statistics scan with no tracked changes to display.
This change lets each status scan finish and coalesces refresh requests received while it runs into one follow-up. Periodic polling resumes after completion, with a cooldown of at least five seconds and nine times the scan duration. Unchanged results and failures also increase the minimum delay up to 60 seconds; the duration-based cooldown can exceed that limit. Explicit refreshes bypass the idle cooldown.
Failed scans retain the last successful status and show a stale warning. Retry timers survive process-launch failures, stale status and repository-discovery events are ignored after repository changes, and shutdown cancels pending status work. Working-tree diff statistics run only for staged or unstaged sections containing tracked changes; commit-view statistics remain available.
Host API 0.17 adds
MonotonicTimefor elapsed-time measurements, while retaining compatibility with 0.16 packages. The schema, compatibility documentation, and focused plugin CI tests are updated together.How to Test
Run the focused tests on Unix:
The gated-process tests verify that slow scans survive old poll events, refresh bursts produce one follow-up, and cooldown grows with scan duration.
git_refresh_failed_output_preserves_the_last_successful_statusverifies cached rows survive failures and the stale warning clears on recovery. The remaining cases cover launch retries, repository changes, shutdown, and statistics selection.Build with
cargo build --release. In a disposable Git repository with a committed file, modify that file and add an untracked file. Launchtarget/release/red --root <repository>and run:GitDashboard. Both changes should appear, with diff counts for the tracked file. Add another file externally and pressr; it should appear promptly during the idle cooldown.Open the dashboard in a clean repository and inspect the editor's Git child processes. Status should complete without starting
git diff --numstat. In a repository where status takes longer than five seconds, the same status process should run to completion. Repeatedrpresses while it runs should queue only one subsequent scan. Once pending work finishes,[git-status] completedlog entries should report a cooldown of at least nine times the scan duration. Pressqto close the dashboard; background polling should retain that scheduling policy. Exit the editor with:q!.Validation at
f63343cbe1bb4ca204a1b404da7a38fd8cc4686a: 3,542 tests passed across 24 targets, with two ignored. The full run had one detached IPC timeout; all four tests in that target passed on an isolated retry without source changes. Release Clippy passed for all targets and features with warnings denied; formatting and Markdown links also passed.In a live large-repository smoke test, two status scans completed in about 69.7 seconds each and scheduled roughly 627 seconds of cooldown, with no overlapping status scans. During approximately 15-second observations with the dashboard closed and then open, there were no Git children and Red averaged under 0.4% of one CPU. These were short cooldown observations, not measurements over the full scheduled interval. Active scans still use multiple cores; this change reduces repeated background work rather than imposing a CPU cap.