Repository navigation
PERF-EDIT: an edit is followed from what it touched, not worked out from every photo (stacked on #1656) - #1660
Merged
Merged
Conversation
8 of 9 tasks
A view is asked again after every edit, so a photo that an edit makes stop matching it leaves the grid at once and every photo after it moves up: a keyword given in a smart album of photos without keywords takes the photo away from under the cursor, and in a random order, with no landmarks, the shift reads as a new shuffle (the seed does not change). View > Hold View Until Refreshed (`library.holdView`, off by default, kept with the library's preferences): a photo the view shows stays in it when an edit makes it stop matching a smart album's rules, Picks or the filter bar. View > Refresh View (`library.refresh`, also in the sort menu while the hold is on), Reshuffle, another source, filter or sort, or new rules for the smart album shown, shows what matches now. - Photos that start matching still appear at once. - A photo that is deleted, or taken out of the album or folder shown, still leaves at once: a held photo has to be where the view looks (`Catalog::query_keeping`, `within`). - A source with no filter over it holds nothing and is queried as before. - A refresh keeps the seed. - The grid's count no longer reads "3 of 2" when a held view shows more than now match its source. Each edit still asks the whole library again; that cost is not addressed here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rom every photo Everything derived from the catalog was keyed on its revision, which every op raises. So each edit (a keyword, a rating, every tick of a slider) had the grid's list queried and sorted again from every photo, the source counted by a second full query, and the side panels tally the whole library again. In a library of 67,000 photos the frame after one keyword took about 156 ms with both side panels open (an idle frame: 2 ms). The catalog now remembers which photos its latest ops touched and what of them they changed (`Catalog::touched_since`, `aspects_since`, `Aspects`). It answers "not known" for an op that changes more than photos of its own (an album, a stack, the keyword list), for changes too long ago, and for a revision it did not make itself (a library just loaded). - The view (`Session::visible`): when the same view is asked again after a small edit, the photos the edit touched are taken out of the list it had, asked about again, and put back at their place in the order (`Catalog::follow`). 37 ms -> 0.6 ms. Worked out whole as before: more than 256 photos touched, a change that is not photos' own, an album in its own order, Recently Added, Missing Photos, and a view that asks about "the last N days" (it changes with the clock too). - The source's count: taken from the list when no filter is set, else counted without sorting (`Catalog::count`). 37 ms -> 0. - The side panels (`Caches`): the folder tree, keyword tree, date groups, people's names and library counts are kept through an edit that changed nothing they read. A rating or a slider changes none; a keyword leaves the folders, dates and counts. The frame after a keyword: about 156 ms -> 54 ms with both side panels open, 71 ms -> 2 ms with the grid alone (`tests_view_cost.rs`, a synthetic library, run with --ignored --nocapture). Still paid on each edit: the count beside every album and smart album in the left panel (about 25 ms for a smart album there), and the filter bar's lists. Tests: 1,440 random edits of every photo-local kind across sources, sorts, filters and the hold, each compared with the list worked out whole; 600 random edits comparing every kept tally with a fresh one; the clock; the record itself, with its failure paths. `ui.inspect` -> `perf` reports `viewFollowed` and `viewWorkedOut`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
added a commit
to nledford/lightcraft
that referenced
this pull request
Oct 14, 2026
…tos it touched The left panel shows a count beside every album. Each catalog revision had every album counted again, and a smart album's count asks every photo of the library whether its rules hold: one pass over the library for each smart album after each keyword, rating or slider tick (about 25 ms an album in a library of 67,000 photos). `AlbumTally` (`crates/catalog/src/tally.rs`) keeps the counts and, for each smart album, which photos it holds. After a small edit each smart album asks only the photos the edit touched (`Catalog::touched_since`); an album of chosen photos is counted again only when a photo came, went or was deleted. Counted from every photo as before: new rules, a change to an album, a stack or the keyword list, an edit to more than 256 photos, another library, and each new minute while an album asks about "the last N days". What an album remembers is in proportion to the photos it holds: a bit a photo id while ids are close together, a set when they are far apart. The frame after a keyword in that library, both side panels open: about 54 ms -> 27 ms (156 ms before storytold#1660). Tests: 900 random edits against eight smart albums (keywords, flags, ratings, labels, sliders, capture dates, file names, an album of chosen photos) and an ordinary one, the followed counts compared with `album_count` after each; a delete followed, three hundred photos counted whole; the members' bits at the edges and for ids far apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thank you @nledford! This landed on main in integration batch 36 (#1843). If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there. |
This was referenced Nov 15, 2026
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.
Stacked on #1656 (both change
Session::visible): the first commit here is its. The commit "PERF-EDIT: an edit is followed from what it touched, not worked out from every photo" is new.Problem
Everything derived from the catalog is keyed on its revision, which every op raises. So each edit, however small (a keyword, a rating, every tick of a slider), costs several passes over the whole library:
Keywording through a large library is where it shows: each keyword is followed by a visible pause.
Measured
crates/ui-egui/src/tests_view_cost.rs(ignored;cargo test -p lightcraft-ui-egui --lib what_one_keyword_costs -- --ignored --nocapture): a synthetic library of 67,000 photos, a third of them keyworded from 500 keywords, showing a smart album of the 44,666 without keywords at random. Test profile (optimized), Apple M1 Max, in memory.An idle frame is about 2 ms. By stage: the view's list 37 ms → 0.6 ms; the source's count 37 ms → 0; folder tree 13.5 ms, date groups 14 ms and library counts 6.5 ms are no longer tallied after a keyword.
It is a synthetic library: a real one has its own albums, keywords, stacks and a disk under it, so the shape should carry over, not the numbers.
Change
crates/catalog/src/lib.rs): which photos, at which revision, and what of them (Aspects: rating, flag, label, develop, metadata, capture date, file, analysis, presence).Catalog::touched_since(revision)andaspects_since(revision)answer "not known" for an op that changes more than photos of its own (an album, a stack, the keyword list, a label's name…), for changes older than the 8,192 it keeps, and for a revision the catalog did not make itself (a library just loaded takes a range of its own). The kinds of op are listed in amatchwith no wildcard, so a new kind has to be put on one side.Session::visible,Catalog::follow): the touched photos are taken out of the list it had, asked about again, and put back at their place by binary search on the same ordering the query sorts by (Sort::order). Worked out whole, as before: more than 256 photos touched, a change that is not photos' own, an album shown in its own order, Recently Added, Missing Photos, and a view that asks about "the last N days" (it changes with the clock, not only with edits).Catalog::count).Cachesincrates/ui-egui/src/lib.rs): each says what it reads of a photo, and is kept when only other things changed. A rating or a slider changes none of them.ui.inspect→perfreportsviewFollowedandviewWorkedOut.Not in this PR:
How it was checked
cargo xtask cion this branch: run gate by gate, see belowTests (8 new):
crates/engine/src/tests_view_follow.rs, 3: 1,440 random edits (ratings, flags, keywords, titles, sliders, capture dates, files located elsewhere, photos added, removed for good, deleted, made Local, stacked, albums filled and emptied, undo) across six sources, six sorts, three filters, with the hold of LR-LIB-SMARTALBUM: a view can hold its photos until it is refreshed #1656 on for half of them: after each, the followed list equals the list worked out whole, and the session is left as it was, so a list followed many times over is what gets compared; a view that asks about the last 30 days loses its photos when the clock moves on, itself and through a smart album that looks into it; an edit to 500 photos, or to an album, is worked out whole, and nothing changed costs nothing.crates/ui-egui/src/tests_tallies.rs, 2: 600 random edits on a library of files in folders: every tally as the panels would show it equals one made from every photo, also when several edits pass between two looks; a rating or a slider keeps all four, a keyword keeps the folders and dates, a deleted photo or a new album keeps none.crates/catalog/src/tests.rs, 1: the record: photos and aspects per revision, each once; a photo that goes counts for everything; a broad op; a revision set from outside; more ops than are kept; an op that fails; a batch that fails midway, a batch in a batch, a batch with a broad op.tests_view_cost.rs: the measurement (ignored).Reviewed by a second agent that had not seen the work. Its one blocker, fixed here: a followed view no longer followed the clock for "in the last N days" rules. Also from it: the test's reference list used to reset what it was checking; the random edits now include the kinds that move a photo in each sort; the tally test now uses photos in folders; the counters moved out of
library.state. Not covered by a test: the people tally (no test names a face),SetContentunder the file-size sort, and the Local browse source.Rebased onto
mainafter integration batch 35 (2026-10-14), with #1656 under it: no conflict.main's catalog changes (Catalog::repairon opening a damaged snapshot,next_photowithsaturating_add,MoveAlbum's bounded cycle check) add no kind of op, so thematchthat classifies every op needed nothing new;repairruns as a library loads, before any view is followed.Run on this branch after the rebase:
cargo fmt --all --check;cargo clippy -p lightcraft-catalog -p lightcraft-engine -p lightcraft-ui-egui --all-targets -- -D warnings(with-A clippy::chunks_exact_to_as_chunks);cargo xtask parity,layers,assets. The suites were not rerun on this branch itself; they were run on #1662, which contains it (see there).Run before the rebase:
cargo fmt --all --check;cargo clippy -p lightcraft-catalog -p lightcraft-engine -p lightcraft-ui-egui -p lightcraft-mcp --all-targets -- -D warnings(with-A clippy::chunks_exact_to_as_chunks, which rustc 1.99 raises incrates/pipelineonmainhere);cargo xtask parity,layers,assets,wasm;cargo testforlightcraft-catalog(199 pass),lightcraft-engine(828 pass),lightcraft-mcp(29 pass),lightcraft-ui-egui(807 pass, 6 fail, all intests_model_setup: "this build cannot run denoise models", the feature being off when this crate is tested alone; untouched here). After those runs only two test files changed (a lint); their tests and clippy were rerun. The whole-workspace run was not repeated.Merging
Session::visibleandCatalog::query(several albums and folders at once), so whichever lands second needs the follow step carried onto the other's filter: I will do that port. perf(catalog): #1136 index stacks and album membership; no per-photo list scans at 100k #1138 (another contributor) indexes stacks and album membership for the same reason, from the other end: it makes the full pass cheaper, this avoids the pass; they do not conflict in intent, and may inquery.rs.unsafe, build scripts, network access, spawned processes, deleted files, CI orxtaskgate changes: none.Checklist
tr(): no new textdocs/parity-checklist.md: no row changes (no feature added);docs/whats-new.mdhas the entry🤖 Generated with Claude Code