perf: prevent repeated status fetches in large repos#2824
perf: prevent repeated status fetches in large repos#2824DannyStoll1 wants to merge 1 commit intogitui-org:masterfrom
Conversation
Replace time-based cache invalidation with a generation counter. The old `StatusParams` included a millisecond timestamp (tick) in its hash, causing the cache to invalidate on every UI tick. For large repos with millions of files, this led to repeated index loading and 5+ minute load times. This change uses a different strategy to manage cache invalidation: - Remove tick from StatusParams hash - Add generation counter that increments after each fetch completes - Include generation in cache hash This ensures: - No repeated fetches while one is already pending, making gitui usable in large repos - New fetch starts immediately after completion, keeping gitui responsive in small repos - External file changes will still be detected on the next fetch cycle
|
Oh wow interesting, I wonder when we broke that. Great find |
|
Thanks for the PR (and the accompanying issue)! I’ll try to have a look over the weekend! |
|
@DannyStoll1 From what I can tell, these lines seem to serve the same purpose: Lines 95 to 98 in 7747d82 Am I missing something? Do you happen to know why they haven’t prevented |
|
Apologies for the delay getting back to you on this.
For instance, this is the event sequence for a single AsyncStatus instance in a large repo where a fetch takes ~13 seconds: Tick is in milliseconds, meaning the hash is always different on the first tick after completion, guaranteeing a cache miss and a new spawn. So This PR tries a different solution: the hash would only change when a fetch completes, so the very next tick after completion gets a miss and starts a new fetch, but ticks that arrive while pending are blocked to prevent queue buildup. The behavior is the same for small repos -- the difference is that the cache invalidation is tied to completion rather than wall clock time, so there's no risk of the hash silently changing between "pending=0" and the next tick. |
This PR fixes/closes #2823
It changes the following:
This ensures:
I followed the checklist:
make checkwithout errors