[Bug]: Slow Dupe Group Change #118
Labels
No labels
Kind/Bug
Kind/Feature
Priority/High
Priority/Medium
Reviewed/Confirmed
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ai-collab/bulk-image-organizer#118
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
App version
0.1.54 Beta
Platform
Windows
Steps to reproduce
Expected behavior
Nearly immediate loading of images from adjacent groups
Actual behavior
A nearly 1 second delay between changing groups then another short one for the images to render to the screen
Additional context
No response
Root cause confirmed: navigating between duplicate groups was invalidating the entire
ImageFilterProxytwice per click — once inset_dupe_group_filterand again in_apply_dupe_group_filter's refresh call — each forcing a full filter+sort pass over every image in the directory, even though the dupe-group filter never affects sort order. With hundreds of images this produces the observed ~1s stall on every group change.Fix pushed to
0.2.0/issue-118-dupe-group-nav-perf(commitc6e1aa0): the group filter now usesinvalidateFilter()instead of a fullinvalidate(), and the redundant second invalidate in_apply_dupe_group_filteris removed. Lint, format, and full test suite (517 passed) are clean. Holding on the branch per workflow until a PR tomainis requested.Found and fixed a second, bigger contributor (commit
69a4b44):DupeMultiGriddestroyed and recreated every comparison tile on every group switch — each tile owns its ownQGraphicsView/QGraphicsScene, so this was real widget-construction cost, not just layout math. Tiles are now pooled by grid position and reused in place (content/size updated, widgets kept alive), which measured ~8x faster per switch in an offscreen benchmark (15.7ms → 1.9ms, excluding image decode/IO).Also removed three redundant per-click DB round trips that were piling onto the same click:
get_all_tags()was being queried separately for the current group and each of the two preloaded neighbors (now computed once and shared), andcount_distinct_dupe_tags()duplicated a count already available from the tag-summary query the status refresh had just run.Combined with the proxy fix from the previous comment, this should bring group-switch latency much closer to single-image viewer navigation. Pushed to
0.2.0/issue-118-dupe-group-nav-perf; full test suite (517 passed) and lint clean.Per the user's request, expanded this branch into a general redundant-call audit across the app (same bug classes as #118: over-broad Qt model invalidation, full widget rebuilds instead of reuse, N+1/duplicate DB round-trips). Five more fixes landed on
0.2.0/issue-118-dupe-group-nav-perf:9644792— generalized theinvalidateFilter()fix to all 10ImageFilterProxysetters (tag filter, search, hide-deleted, orientation, etc.), not just the dupe-group filter. None of these affect sort order, so each was forcing a needless full resort on every filter click/keystroke.9ffbeef—TagPanelwas doing a fulldeleteLater()+recreate of every tag swatch on every grid selection change and every viewer navigation step. Now updates existing buttons' highlight state in place.75d3092— bulk tag/DELETE actions (tag_manager.py) opened one SQLite connection per image for both planning and applying changes — a 200-image selection meant ~800-1000 connections for one keypress. Added bulkWorkingDBhelpers and routed every per-path loop through them.2356a88— same per-path DB loop pattern in twomain_window.pyselection/tag-sync helpers, fixed the same way.80501ba—ImageListModel(the grid's data model) did an O(n) linear scan to find a row by path on every upsert/thumbnail-batch/remove/relocate call, repeated throughout scan and thumbnail-generation progress. Added a path→row index for O(1) lookups, plus batcheddataChangedemissions per call instead of one per item.All changes are covered by new regression tests (including connection-count assertions for the DB batching) and the full suite (536 tests) passes. Branch is pushed but no PR opened yet, per the usual workflow.
Resolved by PR #133 (branch
0.2.0/issue-118-dupe-group-nav-perf, bumped to 0.2.1). Root causes and fixes summarized in the two comments above. Closing.