Skip to content

Cache duplicateGroups + verifiedDuplicateGroups per scanFinishedAt#79

Merged
RasputinKaiser merged 1 commit into
mainfrom
perf/cache-duplicate-groups
Jun 22, 2026
Merged

Cache duplicateGroups + verifiedDuplicateGroups per scanFinishedAt#79
RasputinKaiser merged 1 commit into
mainfrom
perf/cache-duplicate-groups

Conversation

@RasputinKaiser

Copy link
Copy Markdown
Owner

Summary

duplicateGroups and verifiedDuplicateGroups on ScanStore previously recomputed on every property access. For users switching between Duplicate Review and other views, this re-walked size-group / verified-group aggregation each time. v0.4.5 already cached cleanupCandidates this way — this PR applies the same pattern to the two remaining duplicate-side derived properties.

Changes

Adds four cached fields mirroring cachedCleanupCandidates / cachedCleanupCandidatesKey:

  • cachedDuplicateGroupsKey: DerivedCacheKey? + cachedDuplicateGroups: [DuplicateSizeGroup]
  • cachedVerifiedDuplicateGroupsKey: DerivedCacheKey? + cachedVerifiedDuplicateGroups: [VerifiedDuplicateGroup]

Each property checks the key against currentDerivedCacheKey; on miss it recomputes, populates, and returns. invalidateDerivedCaches() now nils all four new cached vars alongside the existing ones.

The cache key already folds scanFinishedAt, query, sizeFilter, sortOption, cleanupLaneFilter, and ignoredCleanupCandidateIDs — selection / filter / scan mutations drop the cache, exactly like cleanupCandidates.

Test plan

  • swift test (54 tests in 5 suites pass)
  • swift build succeeds
  • ./script/public_upload_audit.sh passes
  • No surname "Zvirbulis"; GitHub handle "RasputinKaiser"

🤖 Generated with NCode

Both computed properties currently recompute on every view transition. Mirrors the
cachedCleanupCandidates pattern (key + value pair, nil'd together in
invalidateDerivedCaches) so Duplicate Review navigation between views no longer
re-walks size-group / verified-group aggregation.

Cache fields:
- cachedDuplicateGroupsKey / cachedDuplicateGroups: [DuplicateSizeGroup]
- cachedVerifiedDuplicateGroupsKey / cachedVerifiedDuplicateGroups: [VerifiedDuplicateGroup]

Keyed on currentDerivedCacheKey which folds scanFinishedAt, query, sizeFilter,
sortOption, cleanupLaneFilter, and ignoredCleanupCandidateIDs — matches the existing
cleanup-candidates cache identity so any selection / filter mutation drops the cache.

Co-Authored-By: NCode <noreply@noumena.com>
@RasputinKaiser RasputinKaiser merged commit b43c7b9 into main Jun 22, 2026
6 checks passed
@RasputinKaiser RasputinKaiser deleted the perf/cache-duplicate-groups branch June 22, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant