Repository navigation
PERF-CATALOG: a smart album's per-photo test stops storing an answer nothing can read - #3121
Merged
Merged
Conversation
The outermost question in smart_album_holds inserted its answer into ANSWERS, and the Forget guard cleared the map as the same call returned, so no question could ever read that entry. Each photo still paid a hash and an insert for it. Only answers worked out by a nested question are kept now; they are shared across the outer question as before. No behavior change: EVALUATED is counted before the change, nested answers and the depth and cycle limits are untouched.
Contributor
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Nested answer caching crates/catalog/src/rules.rs |
smart_album_holds checks whether a call is outermost and caches its result only when it is nested. |
Priority:
Estimated code review effort: 1 (Trivial) | ~5 minutes
Change: Refactor
Suggested reviewers: fredapps, echelon
Merge Risk: 
Minimal · up to 58752
-
The cache lifecycle and tally behavior remain correct, with no actionable merge-blocking risk identified.
Pre-merge checks: 
4
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
9 tasks done
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.
Off
main.Problem
Testing one photo against a smart album stored the answer in a per-thread memo (
ANSWERS) that is cleared as the same call returns, so nothing could ever read it. Every photo of a smart album's count or view still paid a hash and an insert for that entry.Change
smart_album_holds(crates/catalog/src/rules.rs) no longer inserts the answer of the outermost question intoANSWERS. Answers worked out by a nested question (a smart album that tests another smart album) are still stored and shared across the outer question, so the protection against repeated work through nested albums stays.EVALUATEDis counted before the change, so the tests that count evaluations see the same numbers.Not in this PR: the memo's other costs, and #2423's cheapest-rule-first ordering. How much of any larger slowdown seen elsewhere this explains is not shown here.
How it was checked
cargo xtask cipasses on this branch, rebased on currentmain: all 8 steps (fmt, clippy, heif, test, parity, layers, assets, wasm) on this Mac.maincurrently fails clippy atnative_menu.rs:492on macOS (MENU-BAR: clippy passes on macOS again (Quit, About and Settings share one branch) #2973 fixes it); that one-line fix was applied uncommitted for the run and is not in this PR.cargo test -p lightcraft-catalogfiltered tosmart_albumandrules: 31 passed, 0 failed).Measured with
lightcraft-cli run --library <clone> library.source kind=all album.createSmart …(four creations of a smart album with the rule{"flag":"reject"}per run), release builds ofmain(c9860ea) and of this branch, a fresh APFS clone of the library per run, backups off, minimum of the 4 creations per run. The library is a generated format-9 catalog of 532,850 library photos (every fifth one rejected), made with a throwaway version ofcrates/catalog/examples/persist_bench.rs; no real library was used. The Mac was busy with other builds, so the load is recorded:mainmain's run / this branch'sThe branch is faster in every round (by 33, 16 and 26 ms), including the two rounds where it ran at the higher load. The size of the gain is noisy at this load; the direction is not.
Review: fresh reviewer at 5875299
Screenshots
None: not a visible change.
Merging
crates/catalog/src/rules.rs, but around line 488, not insmart_album_holds's insert; LR-LIB-FOLDER: a folder of albums shows the photos of the albums inside it #768 and LR-LIB-FOLDER: smart albums in album folders keep off loops (stacked on #768) #776 do not touch the memo.ANSWERSget and insert undersmart_album_holds. The code ismain's own, so it is measured here onmainalone.unsafe, build scripts, network access, spawned processes, deleted files, CI orxtaskgate changes: none.Checklist
tr(): no new textdocs/parity-checklist.mdand its entry indocs/gaps.mdare updated: no feature row changesassets/ATTRIBUTION.md: none addedSummary by CodeRabbit