Skip to content

Find videos in large SMB libraries faster - #85

Merged
seaweeduk merged 2 commits into
masterfrom
performance/library-scans
Nov 19, 2026
Merged

seaweeduk merged 2 commits into
masterfrom
performance/library-scans

Conversation

@seaweeduk

Copy link
Copy Markdown
Owner
  • Discover folders concurrently over SMB instead of waiting for each listing before requesting the next. Requests stay bounded and share the existing connection with browsing and playback.
  • Make automatic repeat scans reuse verified, unchanged folders with no videos or subfolders. Still check deeper branches and folders containing videos. Manual refresh checks everything, as do automatic scans when full verification is a day old.
  • Preserve the existing cache on upgrade and save unfinished requests for the next launch. Keep SFTP scanning one folder at a time so it does not queue ahead of browsing.

Relative results from the same SMB workload:

Unchanged repeat scan Before After
Directory listings Full-tree traversal About 99% fewer listings
Completion time Still running at the measurement cutoff Finished in less than 5% of that cutoff

Important

AI disclosure

Model Variant Role
openai/gpt-6.1-sol high Planning, implementation and measurement
openai/gpt-6-astra high Independent review

Agent harness OpenCode 2.3.0

@seaweeduk seaweeduk added the performance Faster or smoother (release notes: Performance) label Nov 19, 2026
@opencode-agent

Copy link
Copy Markdown
  1. Medium — Resuming a scan of / can erase the folder being updated and crash. src/library_index.cpp:390–393 links every restored work item to its parent. If the user pins the File System place while playback has paused scanning, / can be saved as pending. On restart, parentOf("/") is /, so the root becomes its own child. The next apply("/") treats that child as gone, calls dropFolder("/"), then uses the erased Folder& to insert the actual children. Skip pinned roots when reconstructing parent links, as the folder-loading loop at lines 374–377 already does.

  2. Medium — One unavailable pin disables fast repeat scans for healthy SMB pins. src/library_index.cpp:607,662,670 uses one verification timestamp for all roots and advances it only if none failed. With a large SMB library and an unplugged pinned drive, a full scan can verify every folder on the SMB share yet leave verifiedAt expired. Every subsequent launch then lists the entire share again, bypassing even leaves verified minutes earlier. Track full verification for the roots actually scanned successfully, so the unavailable root remains due without forcing another full traversal of the healthy share.

  3. Medium — Manual refresh can be lost during an automatic scan. src/library_index.cpp:266–281 consumes again but starts a full scan only when !looking(). The refresh button remains actionable during a scan, including one paused for playback. Previously the running scan already enumerated every folder; now it can skip leaves, so pressing refresh no longer guarantees full verification. Retain one full-refresh request when an incremental scan is active and run it from all roots. Merely switching fullLook midway would miss leaves already skipped.

  4. Low — A Stash generated directory can be cached as an empty leaf. At src/library_index.cpp:698–706, sift() clears the listing of a recognized generated directory before its stamp is saved. On the next launch, skip() can therefore skip that directory, leaving the process-local generated set empty. Opening a descendant directly, for example through a nested pin, then lets the browser feed preview clips back into the Library when no Stash catalog filters them by hash. Only save a skip-eligible stamp when the scan found no videos or subfolders before Stash filtering.

  5. Low — An unreadable child keeps backdating newly discovered videos. src/library_index.cpp:713–714 now marks the whole pin failed for a denied subfolder. On a new pin with a permanently restricted child, lookedAt consequently stays zero after every pass. apply() uses that same zero to identify the first scan, so a video copied into an accessible folder weeks later is recorded with its old file modification time instead of its discovery time and sorts incorrectly by date added. Keep first-pass bookkeeping separate from successful full verification: a partial tree should remain due for verification without treating every subsequent discovery as part of the initial import.

github run

@seaweeduk
seaweeduk force-pushed the performance/library-scans branch from 588838a to ed205f9 Compare November 19, 2026 23:22
@seaweeduk
seaweeduk changed the base branch from fix/library-stash-generated to master November 19, 2026 23:22
@seaweeduk
seaweeduk merged commit 56309f0 into master Nov 19, 2026
3 checks passed
@seaweeduk
seaweeduk deleted the performance/library-scans branch November 19, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Faster or smoother (release notes: Performance)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant