Repository navigation
LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched - #2054
Conversation
1d7c66e to
6ab5bcb
Compare
FredApps
left a comment
There was a problem hiding this comment.
This is a comment rather than an approval only because one hosted job did not finish. I found no defect in the change. I have not built or run it.
Hosted result at 6ab5bcb7. freebsd / FreeBSD 15 x86_64 (build + test) passed (it runs cargo test --workspace --locked; I checked its log: 1,147 tests passed in the UI crate, and both new tests, a_batch_of_new_photos_or_an_edit_to_one_is_read_photo_by_photo and a_grid_followed_through_edits_shows_what_a_grid_made_afresh_shows, ran and passed). windows-arm64 / package and install and run on ARM64 passed. freebsd / FreeBSD 15 aarch64 (build + test) was cancelled after running from 19:21 to 00:21 (about five hours, so it looks like a runner or timeout cancel, not a test result), and CodeRabbit reports nothing. Please re-run the aarch64 job; once it is green I have nothing further to ask for.
What I read. The whole code diff: catalog/src/dates.rs, ui-egui/src/panels/grid.rs and ui-egui/src/tests_grid.rs. I did not read the docs edits beyond the file names, or the catalog's touched_since/revision implementation that follow depends on (it is not in this diff).
What I checked, and it holds.
- Refactor of
date_runs.date_groupis the olddate_ofclosure unchanged (same key choice, same ISO check, same prefix),groups_by_dateis the old early returns, anddate_runs_ofkeeps the stack rule: a stack's members take the group of the first photo of the stack met in the list.Catalog::date_runsnow calls the two, so the catalog tests keep covering the old behaviour. - Following a list.
ListRead::followreuses a photo's stored group and shape only when it is untouched since the last read and is where it was among the other untouched photos; it falls back to a whole read when the grouping, shape mode or order changed, whentouched_sincereturnsNone, when more than 4,096 photos were touched, or when an untouched photo left the list. Photos touched are read again wherever they are now, so a changed capture date or crop lands correctly. - Cache keys. The old runs cache is kept but now also requires that the shape data matches the mode (
shapes.is_some() == shaped), so toggling Photo grid and Square grid rebuilds instead of showing stale shapes. - Tests. The first test pins the cost (16 photos read for a 16-photo batch, 1 for a capture-time edit) and the visible result (new day header). The second runs 120 seeded random edits (import, delete, capture time, rotate, crop, rating, sort, stack, undo, flag, view toggle, filter) and after each compares the cache's runs and shapes with a grid built afresh from the catalog, which is the right check for this kind of cache.
Non-blocking points.
- The group names are never pruned.
namesandnamedcarry over on every follow and are only reset by a whole read, so a long session of capture-time edits to many different days grows them. The cost is a short string per distinct day or month, so I mention it only because the code comment says an import adds "a day or two at most" and edits can add more. - Switching grid mode rereads everything. A change from Photo grid to Square grid (or back) makes
followreturnNoneat once and reads every photo again, about the 100 ms the PR is removing, on each toggle. That is rare, but a note would save a reader wondering. - One seed. The random test uses a fixed seed (
dice = 11), so it checks one 120-step path. Running a few seeds in a loop would make it a broader regression net at no real cost.
Not covered. FreeBSD aarch64 (cancelled), macOS, and x64 Windows tests.
|
@FredApps thank you, these were good suggestions.
|
FredApps
left a comment
There was a problem hiding this comment.
Read the whole diff at this head. The incremental read is sound.
ListRead::followre-reads only the photostouched_sincereports, takes the rest over by position, and falls back to a whole read whenever an untouched photo is not where it was, an untouched photo left the list, the sort/grouping/mode changed, or more thanMAX_FOLLOWEDphotos were touched. Stack edits returnNonefromtouched_since, so they read whole, and stack members still take their first photo's group because the runs are built throughdate_runs_of.date_runsnow goes through the samedate_group/date_runs_ofpath, so there is one definition of a group.- The randomized test compares the followed grid with a grid made afresh across imports, deletes, capture times, rotation, crops, sorts, stacks, undo, filters and view switches. That is the right check for this kind of cache.
Nit, no change needed: names only grows between whole reads. The comment says so and the growth is a short string per new day, so that is fine.
FreeBSD x86_64 build + test and the Windows ARM64 jobs are green at this head.
…an edit touched Every catalog change gave the grid a new list of photos, and it read every photo of it again: each one's date group (a lookup, a date parse and a string) and its cell's shape. At 180,000 photos that was a 100 ms frame for every batch an import added. - catalog: Catalog::date_runs is split into date_group (one photo's own group) and date_runs_of (the stack rule and the runs), which the grid uses too. - ui: GridCache keeps what it read of each photo of the list, position by position. A new list that differs by the photos the catalog says an edit touched is read again only for those; anything else (another view, order or grouping, a stack) is read whole. The square grid reads no shapes. A 16-photo batch at 181,749 photos: 101 ms -> 7 ms. Co-Authored-By: Claude <noreply@anthropic.com>
…ch and the names The random-edit test now runs five seeds instead of one. A grid-mode change re-reading every photo, and the group names growing unpruned, are now said in the comments (the "a day or two at most" claim was wrong for capture-time edits). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto |
2bf118c to
53ee384
Compare
The PR's branch carried a second header line; its change note joins the existing one.
…h develop edits The caches still keyed on the raw catalog revision move to `still_right`: keyword names, chips, groups and ticks, the filter bar's values, keyword completions and suggestions (what they read: photos' metadata), the selection count, smart-album problems, face hints and the Missing count (anything but develop state), People and the rule dialog's count (develop state only when the filter or rules, or a smart album they test, read it). A kept entry moves its revision on, so the change record it asks stays short. The grid's list now stays the same through a develop edit when the view reads no develop state, so its date runs and stack index aren't rebuilt. Cell shapes (crop, orientation) are develop state: on a kept list, `GridCache::reshape` reads again the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and the justified layout keys on `GridCache::shapes`, moved on each time it does. `ui.inspect` -> `perf` reports `viewKept`. Tests: 20 develop ticks keep the trees, keyword lists, filter values, People, suggestions, smart-album problems and the rule dialog's count, while rules testing Has Edits, Cropped or such an album follow the edits; `develop.set` through the control channel keeps the grid's list, runs and stack index (and the square layout), and a rotation still re-lays the justified grid with the list unchanged, its cells as a grid made afresh shows them. storytold#2054's randomized check (rotations and crops among its edits) holds with the lists now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cell's shape changed On a kept list, `GridCache::reshape` reads the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and moves `GridCache::shapes`, the justified layout's key, only when one of them is not what it was. Only a crop or a rotation changes a cell's shape, so an exposure tick no longer lays out the whole grid again. Frame after an exposure tick, 67k photos, Photo Grid alone, headless app, release (median of 10 runs of the median of 40 ticks): 2.8 ms -> 2.5 ms, with a layout on every tick before and none now (main: 7.5 ms). Test: `develop_edits_keep_the_grid_view` checks that exposure ticks lay out neither grid, and that a rotation still lays out the Photo Grid again with the list kept, its cells as a grid made afresh shows them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h develop edits The caches still keyed on the raw catalog revision move to `still_right`: keyword names, chips, groups and ticks, the filter bar's values, keyword completions and suggestions (what they read: photos' metadata), the selection count, smart-album problems, face hints and the Missing count (anything but develop state), People and the rule dialog's count (develop state only when the filter or rules, or a smart album they test, read it). A kept entry moves its revision on, so the change record it asks stays short. The grid's list now stays the same through a develop edit when the view reads no develop state, so its date runs and stack index aren't rebuilt. Cell shapes (crop, orientation) are develop state: on a kept list, `GridCache::reshape` reads again the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and the justified layout keys on `GridCache::shapes`, moved on each time it does. `ui.inspect` -> `perf` reports `viewKept`. Tests: 20 develop ticks keep the trees, keyword lists, filter values, People, suggestions, smart-album problems and the rule dialog's count, while rules testing Has Edits, Cropped or such an album follow the edits; `develop.set` through the control channel keeps the grid's list, runs and stack index (and the square layout), and a rotation still re-lays the justified grid with the list unchanged, its cells as a grid made afresh shows them. storytold#2054's randomized check (rotations and crops among its edits) holds with the lists now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cell's shape changed On a kept list, `GridCache::reshape` reads the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and moves `GridCache::shapes`, the justified layout's key, only when one of them is not what it was. Only a crop or a rotation changes a cell's shape, so an exposure tick no longer lays out the whole grid again. Frame after an exposure tick, 67k photos, Photo Grid alone, headless app, release (median of 10 runs of the median of 40 ticks): 2.8 ms -> 2.5 ms, with a layout on every tick before and none now (main: 7.5 ms). Test: `develop_edits_keep_the_grid_view` checks that exposure ticks lay out neither grid, and that a rotation still lays out the Photo Grid again with the list kept, its cells as a grid made afresh shows them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h develop edits The caches still keyed on the raw catalog revision move to `still_right`: keyword names, chips, groups and ticks, the filter bar's values, keyword completions and suggestions (what they read: photos' metadata), the selection count, smart-album problems, face hints and the Missing count (anything but develop state), People and the rule dialog's count (develop state only when the filter or rules, or a smart album they test, read it). A kept entry moves its revision on, so the change record it asks stays short. The grid's list now stays the same through a develop edit when the view reads no develop state, so its date runs and stack index aren't rebuilt. Cell shapes (crop, orientation) are develop state: on a kept list, `GridCache::reshape` reads again the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and the justified layout keys on `GridCache::shapes`, moved on each time it does. `ui.inspect` -> `perf` reports `viewKept`. Tests: 20 develop ticks keep the trees, keyword lists, filter values, People, suggestions, smart-album problems and the rule dialog's count, while rules testing Has Edits, Cropped or such an album follow the edits; `develop.set` through the control channel keeps the grid's list, runs and stack index (and the square layout), and a rotation still re-lays the justified grid with the list unchanged, its cells as a grid made afresh shows them. storytold#2054's randomized check (rotations and crops among its edits) holds with the lists now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cell's shape changed On a kept list, `GridCache::reshape` reads the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and moves `GridCache::shapes`, the justified layout's key, only when one of them is not what it was. Only a crop or a rotation changes a cell's shape, so an exposure tick no longer lays out the whole grid again. Frame after an exposure tick, 67k photos, Photo Grid alone, headless app, release (median of 10 runs of the median of 40 ticks): 2.8 ms -> 2.5 ms, with a layout on every tick before and none now (main: 7.5 ms). Test: `develop_edits_keep_the_grid_view` checks that exposure ticks lay out neither grid, and that a rotation still lays out the Photo Grid again with the list kept, its cells as a grid made afresh shows them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h develop edits The caches still keyed on the raw catalog revision move to `still_right`: keyword names, chips, groups and ticks, the filter bar's values, keyword completions and suggestions (what they read: photos' metadata), the selection count, smart-album problems, face hints and the Missing count (anything but develop state), People and the rule dialog's count (develop state only when the filter or rules, or a smart album they test, read it). A kept entry moves its revision on, so the change record it asks stays short. The grid's list now stays the same through a develop edit when the view reads no develop state, so its date runs and stack index aren't rebuilt. Cell shapes (crop, orientation) are develop state: on a kept list, `GridCache::reshape` reads again the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and the justified layout keys on `GridCache::shapes`, moved on each time it does. `ui.inspect` -> `perf` reports `viewKept`. Tests: 20 develop ticks keep the trees, keyword lists, filter values, People, suggestions, smart-album problems and the rule dialog's count, while rules testing Has Edits, Cropped or such an album follow the edits; `develop.set` through the control channel keeps the grid's list, runs and stack index (and the square layout), and a rotation still re-lays the justified grid with the list unchanged, its cells as a grid made afresh shows them. storytold#2054's randomized check (rotations and crops among its edits) holds with the lists now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cell's shape changed On a kept list, `GridCache::reshape` reads the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and moves `GridCache::shapes`, the justified layout's key, only when one of them is not what it was. Only a crop or a rotation changes a cell's shape, so an exposure tick no longer lays out the whole grid again. Frame after an exposure tick, 67k photos, Photo Grid alone, headless app, release (median of 10 runs of the median of 40 ticks): 2.8 ms -> 2.5 ms, with a layout on every tick before and none now (main: 7.5 ms). Test: `develop_edits_keep_the_grid_view` checks that exposure ticks lay out neither grid, and that a rotation still lays out the Photo Grid again with the list kept, its cells as a grid made afresh shows them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h develop edits The caches still keyed on the raw catalog revision move to `still_right`: keyword names, chips, groups and ticks, the filter bar's values, keyword completions and suggestions (what they read: photos' metadata), the selection count, smart-album problems, face hints and the Missing count (anything but develop state), People and the rule dialog's count (develop state only when the filter or rules, or a smart album they test, read it). A kept entry moves its revision on, so the change record it asks stays short. The grid's list now stays the same through a develop edit when the view reads no develop state, so its date runs and stack index aren't rebuilt. Cell shapes (crop, orientation) are develop state: on a kept list, `GridCache::reshape` reads again the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and the justified layout keys on `GridCache::shapes`, moved on each time it does. `ui.inspect` -> `perf` reports `viewKept`. Tests: 20 develop ticks keep the trees, keyword lists, filter values, People, suggestions, smart-album problems and the rule dialog's count, while rules testing Has Edits, Cropped or such an album follow the edits; `develop.set` through the control channel keeps the grid's list, runs and stack index (and the square layout), and a rotation still re-lays the justified grid with the list unchanged, its cells as a grid made afresh shows them. storytold#2054's randomized check (rotations and crops among its edits) holds with the lists now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cell's shape changed On a kept list, `GridCache::reshape` reads the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and moves `GridCache::shapes`, the justified layout's key, only when one of them is not what it was. Only a crop or a rotation changes a cell's shape, so an exposure tick no longer lays out the whole grid again. Frame after an exposure tick, 67k photos, Photo Grid alone, headless app, release (median of 10 runs of the median of 40 ticks): 2.8 ms -> 2.5 ms, with a layout on every tick before and none now (main: 7.5 ms). Test: `develop_edits_keep_the_grid_view` checks that exposure ticks lay out neither grid, and that a rotation still lays out the Photo Grid again with the list kept, its cells as a grid made afresh shows them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…h develop edits The caches still keyed on the raw catalog revision move to `still_right`: keyword names, chips, groups and ticks, the filter bar's values, keyword completions and suggestions (what they read: photos' metadata), the selection count, smart-album problems, face hints and the Missing count (anything but develop state), People and the rule dialog's count (develop state only when the filter or rules, or a smart album they test, read it). A kept entry moves its revision on, so the change record it asks stays short. The grid's list now stays the same through a develop edit when the view reads no develop state, so its date runs and stack index aren't rebuilt. Cell shapes (crop, orientation) are develop state: on a kept list, `GridCache::reshape` reads again the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and the justified layout keys on `GridCache::shapes`, moved on each time it does. `ui.inspect` -> `perf` reports `viewKept`. Tests: 20 develop ticks keep the trees, keyword lists, filter values, People, suggestions, smart-album problems and the rule dialog's count, while rules testing Has Edits, Cropped or such an album follow the edits; `develop.set` through the control channel keeps the grid's list, runs and stack index (and the square layout), and a rotation still re-lays the justified grid with the list unchanged, its cells as a grid made afresh shows them. storytold#2054's randomized check (rotations and crops among its edits) holds with the lists now kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cell's shape changed On a kept list, `GridCache::reshape` reads the shapes of the photos `touched_since` the list was read (storytold#2054's `ListRead`), and moves `GridCache::shapes`, the justified layout's key, only when one of them is not what it was. Only a crop or a rotation changes a cell's shape, so an exposure tick no longer lays out the whole grid again. Frame after an exposure tick, 67k photos, Photo Grid alone, headless app, release (median of 10 runs of the median of 40 ticks): 2.8 ms -> 2.5 ms, with a layout on every tick before and none now (main: 7.5 ms). Test: `develop_edits_keep_the_grid_view` checks that exposure ticks lay out neither grid, and that a rotation still lays out the Photo Grid again with the list kept, its cells as a grid made afresh shows them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Off
main.Part of #1130: the grid reads only the photos a batch added, so they appear sooner.
Problem
Every catalog change gives the grid a new list of photos. It then read every photo of the list again:
At 181,749 photos that took about 100 ms. An import or Synchronize Folder adds photos about 16 at a time, so the window lost a tenth of a second for every batch, for as long as the import ran.
Change
crates/catalog/src/dates.rs:Catalog::date_runsis split in two, anddate_runsnow calls both:Catalog::date_groupgives one photo's own group.date_runs_ofapplies the stack rule (a stack's photos take the group of its first photo in the list) and makes the runs.The grid uses the same two functions, so its headers are the same as
library.groups.crates/ui-egui/src/panels/grid.rs:GridCachekeeps what it read of each photo of the list, position by position: its date group and its cell's shape. For a new list, the photos the catalog says changed since (touched_since, at most 4,096) are read again wherever they are now. The other photos are taken over, after checking that they are still in the same order with none added or removed. Otherwise the whole list is read, as before:The runs are made again from the groups and the stack index every time. The square grid reads no shapes. A new counter,
GridStats::photos_read, counts the photos read.Docs:
docs/whats-new.md, and a revision-history line for LR-VIEW-PHOTOGRID indocs/parity-checklist.md.Not in this PR:
Session::visible()for each batch. perf: slider ticks keep views that read no develop state #1152 is reworking that code.touched_sincedoesn't remember photo changes across those edits. With LRC-LIB-LIBFOLDERS: importing into a large library keeps the window responsive #2047'sphotos_changed_sincethe grid could keep following there too.How it was checked
cargo xtask cipasses on this branch, which is on currentmain: all 8 steps.Tests that fail without this change:
tests_grid::a_batch_of_new_photos_or_an_edit_to_one_is_read_photo_by_photo:I checked that a version that skips re-reading touched photos fails it.
tests_grid::a_grid_followed_through_edits_shows_what_a_grid_made_afresh_shows: 120 random edits, each followed by a check that the grid's date runs and cell shapes equal a fresh computation. The edits are imports, deletes, capture times, rotations, crops, ratings, picks, sorts, stacks, undo, the Picks filter, and switching between the photo and square grids.Measured with a throwaway headless test, not committed. Release build, 181,749 photos with dates in 900 folders, photo grid; first frame after a 16-photo batch, median of 20:
mainThe sidebar shown on this PR alone is LRC-LIB-LIBFOLDERS: importing into a large library keeps the window responsive #2047's part: the sidebar counting every photo after each batch.
An independent review pass found no blocker. Its three follow-ups are done here:
Screenshots
None: the grid looks the same. What changes is how long a frame takes during an import.
Merging
Overlap: perf: slider ticks keep views that read no develop state #1152 also changes
GridCacheinpanels/grid.rs:shapespart to the layout key, so the layout follows develop edits when the list is kept.touched_since).The two touch neighbouring lines, so whichever lands second has a small textual conflict, and its layout key needs both. The code of LRC-LIB-LIBFOLDERS: importing into a large library keeps the window responsive #2047 and LRC-LIB-LIBFOLDERS: Synchronize Folder says it is listing the folder instead of sitting at "0 of N" #2049 merges with this one without conflicts; only the lines each adds to
docs/whats-new.mdand thedocs/parity-checklist.mdheader and history meet. I checked that on my integration branch, where all three PRs from today are merged with the other open ones.Existing edits and libraries: unchanged. Nothing is saved.
Shared numbers taken: none.
New dependencies,
unsafe, build scripts, network access, spawned processes, deleted files, CI orxtaskgate changes: none.Checklist
get, and a read that doesn't line up falls back to reading the whole list.docs/whats-new.mdand thedocs/parity-checklist.mdrevision history are updated.grid::show_inner,Catalog::date_runs).🤖 Generated with Claude Code
Summary by CodeRabbit