stash/pkg
notsafeforgit acc5438af2 perf: massive optimization for image and scene duplicate detection
This update provides significant performance improvements for both image and scene duplicate searching:

1. Optimized the core Hamming distance algorithm in pkg/utils/phash.go:
   - Uses native CPU popcount instructions (math/bits) for bit counting.
   - Pre-calculates hash values to eliminate object allocations in the hot loop.
   - Halves the number of comparisons by leveraging the symmetry of the Hamming distance.
   - The loop is now several orders of magnitude faster and allocation-free.

2. Solved the N+1 database query bottleneck:
   - Replaced individual database lookups for each duplicate group with a single batched query for all duplicate IDs.
   - This optimization was applied to both Image and Scene repositories.

3. Simplified the SQL fast path for exact image matches to remove redundant table joins.
2026-03-20 15:06:05 -07:00
..
exec Fix/ffprobe unmarshalling error (#2685) 2022-06-22 10:49:14 +10:00
ffmpeg Custom sprite generation (#6588) 2026-02-20 15:09:59 +11:00
file feat: Add .stashignore support for gitignore-style scan exclusions (#6485) 2026-03-04 08:17:14 +11:00
fsutil Fix new panic in IsFsPathCaseSensitive: Use filepath operations to check for file system case sensitivity (#6635) 2026-03-03 08:11:55 +11:00
gallery Fix stale browser-cached thumbnails after file content changes during scan. (#6622) 2026-03-02 15:53:02 +11:00
group Backend support for Group custom fields (#6596) 2026-02-23 11:53:12 +11:00
hash Use ffmpeg as a general fallback when generating phash (#6641) 2026-03-05 07:58:51 +11:00
image Add Selective generate (#6621) 2026-03-03 09:11:28 +11:00
javascript Add package docs and project vision/goals (#5169) 2024-08-28 09:01:39 +10:00
job Replace ValueOnlyContext with context.WithoutCancel (#6379) 2025-12-08 07:59:42 +11:00
logger Log errors returned from graphql (#3562) 2023-04-17 15:27:25 +10:00
match Feature: Tag StashID support (#6255) 2025-11-13 14:24:09 +11:00
models feat: Implement Image Duplicate Checker 2026-03-13 15:23:02 -07:00
performer FR: Change Career Length to Career Start and Career End (#6449) 2026-02-17 13:44:03 +11:00
pkg Add package docs and project vision/goals (#5169) 2024-08-28 09:01:39 +10:00
plugin [packaging] switch to pnpm (#6186) 2025-11-10 09:17:25 +11:00
python Add package docs and project vision/goals (#5169) 2024-08-28 09:01:39 +10:00
savedfilter Maintain saved filters in full export/import (#5465) 2024-11-12 16:59:28 +11:00
scene Fix stale browser-cached thumbnails after file content changes during scan. (#6622) 2026-03-02 15:53:02 +11:00
scraper FR: Change Career Length to Career Start and Career End (#6449) 2026-02-17 13:44:03 +11:00
session [Feature] Reveal file in system file manager from file info panel (#6587) 2026-02-23 12:51:35 +11:00
sliceutil feat: auto-remove duplicate aliases (#6514) 2026-02-04 10:37:15 +11:00
sqlite perf: massive optimization for image and scene duplicate detection 2026-03-20 15:06:05 -07:00
stashbox FR: Tags Tagger (#6559) 2026-02-25 11:39:14 +11:00
studio Feature Request: Add organized flag to studios (#6303) 2026-02-19 09:05:17 +11:00
tag Merge tag values dialog (#6552) 2026-02-11 11:27:57 +11:00
txn Database connection pool refactor (#5274) 2024-09-20 12:56:26 +10:00
utils perf: massive optimization for image and scene duplicate detection 2026-03-20 15:06:05 -07:00