Repository navigation
Stop obsolete folder counts during directory traversal - #119
Conversation
[Medium impact] The PR appears safe to merge with the explicitly accepted delay when Qt skips hidden entries. SummaryAdds a stop check inside
Reviews (2) · Last reviewed commit: "Check for a stale count in the existing ..." · Reviewed by Greptile |
|
Reviewed at 1a7e72d by Claude Opus 5.5, with Codex Medium and muse-wonder (via pi, thinking high) as second opinions. Nothing found to fix, and nothing was pushed. The bug is real. On a disposable Arch worker, a model loaded a folder of four subfolders holding 400,000 files each and was sent elsewhere 30 ms into counting. On main (bb94499) the thread pool stayed busy 112–160 ms after leaving, and strace saw 330–339 more The cancellation holds up. The predicate is checked before each iterator advance; a Tests. Second opinions. Both found no defect and agreed with the above; they can read this review's notes, so that agreement is not guaranteed to be independent. muse-wonder pointed out that the previewer's Related. #116 (separate pools for listings and counts) is complementary: it keeps counts from holding up listings, this stops the counts themselves, and with only two counting threads there this matters more. The two merge together without conflict. #92 and #89 change the same Waiting on the maintainer. |
The maintainer asked for the simplest version. The stop check sits in the loop itemCount() already had, as list() does, and hidden entries are filtered by Qt as before. Its only caller already checks before each folder and drops an overtaken result, so the checks before and after the loop add nothing, and one assertion in the existing count test covers stopping mid-folder. The price is that a long run of hidden entries, with hidden files off, is stepped over inside Qt before the check runs again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
The maintainer asked for this pull request in its simplest form, so I pushed bf301a1 on top of your branch, @k-kostin. It keeps your fix and drops what the one caller doesn't need. The change is now +13/-6 (src +10/-6, tests +3) instead of +49/-7. What changed, and why
What this gives up. With hidden files off, a long run of hidden entries inside one subfolder is stepped over inside Qt before the check runs again. Cancellation can lag across that run. The wasted work is limited to that run, and no wrong count is ever shown. Your description still describes the hidden-entry handling and the larger test, so read this comment for the current state. Verified at bf301a1 on a disposable Arch worker. A model loaded a folder of four subfolders holding 400,000 files each and moved away 30 ms into counting:
Second opinions. Codex Medium and muse-wonder (via pi, thinking high) reviewed it twice. Both said nothing more is worth removing:
Both named the hidden-entry lag above as the only case given up. Their one finding was that the header comment overpromised for an empty folder, and it now says "stopped partway". They can read this review's notes, so their agreement is not guaranteed to be independent. GitHub's Test workflow has still not run here, because it is waiting for a maintainer to approve it for a first-time contributor. Waiting on the maintainer. |
Summary
Leaving a folder invalidates its count job, but a count already running still enumerates the entire child directory. Pass the existing generation predicate into that loop so navigation, refresh or model destruction can stop obsolete work.
Include hidden entries in the iterator, then exclude them from the total when hidden files are off. Otherwise Qt can filter a long hidden run internally without yielding to the cancellation check. Linux hidden-name semantics and exclusion of
./..are preserved.Based directly on
main; no dependency on #67, #117 or #118. Complements #116's pool separation by avoiding wasted counting itself. No dependency or thread-pool change.Evidence
readdir64()by 500 µs per entry; it measures queue contention, not ordinary SSD navigation. Give folder listings their own thread pool #116 may remove that listing contention independently.git diff --checkpass. Final complete local suite: 197 passed, 0 failed, using Qt image plugins matching the CI dependency set. Regression covers cancellation during enumeration, before starting, empty/hidden directories and a complete retry. Independent review found no remaining issues.Merge Danger
Door: two-way.
Blast Radius: folder counters. Cancellation is cooperative between iterator advances and cannot interrupt an already blocked filesystem call. The previewer's separate folder-summary path is unchanged.