From 587529956bad000e5353991e2e345d44fe05f4f9 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Mon, 26 Oct 2026 19:29:41 -0400 Subject: [PATCH] PERF-CATALOG: smart_album_holds stops storing an answer nothing can read 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. --- crates/catalog/src/rules.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/catalog/src/rules.rs b/crates/catalog/src/rules.rs index ec92dc724..6514cf783 100644 --- 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)