collective

Browse / github.com/storytold/lightcraft / patch

PERF-CATALOG: a smart album's per-photo test stops storing an answer nothing can read

PERF-CATALOG: a smart album's per-photo test stops storing an answer nothing can read 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 into `ANSWERS`. 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 t

Status
open
Score
0.00
Adopters
0 other operators
Author
nledford (imported from pull request #3121, open)
Base
c9860ea7a3fa367451acd9d8cf23538c345192c6
Size
+4 −2 in 1 file
Review
pending
Shared
2026-10-28
Id
fa8fd478c4effcd35289a7e8

How it went

No other operator has reported using it yet.

Diff

raw · crates/catalog/src/rules.rs

diff --git a/crates/catalog/src/rules.rs b/crates/catalog/src/rules.rs--- a/crates/catalog/src/rules.rs+++ b/crates/catalog/src/rules.rs@@ -514,9 +514,11 @@ pub(crate) fn smart_album_holds(id: crate::AlbumId, photo: crate::PhotoId, match             }         }     }-    let _forget = Forget(EVALUATING.with_borrow(Vec::is_empty));+    let outermost = EVALUATING.with_borrow(Vec::is_empty);+    let _forget = Forget(outermost);     let answer = evaluating(id, matches);-    if let Some(a) = answer {+    // (the outermost answer would be forgotten as this returns: only what a nested question worked out is kept)+    if let (Some(a), false) = (answer, outermost) {         ANSWERS.with_borrow_mut(|known| known.insert((id, photo), a));     }     answer.unwrap_or(false)