Repository navigation
Project VIC import: find files from one listing per folder, show progress - #322
Merged
Merged
Conversation
…ress A 627 MB VIC case export (380,000 entries) sat on "Scanning sources" with nothing written for minutes. iter_records resolved every entry's path on its own, and on Windows Path.resolve() is five GetFinalPathName calls and two link reads per path: 84% of the time spent reading the file. Nothing reported progress until every entry was registered. Each folder is now resolved once and listed once (projectvic._Locator), and each entry is a lookup in that listing. An existing file keeps the spelling the disk gives it, which is what resolve() returned, so a row is keyed on the same path as before. import_vic takes progress(n, what) and reports "Reading Project VIC entries" and "Registering files"; the web job shows it. Measured on Windows 11, Python 3.12, a synthetic 627 MB file of 380,000 entries with a file present for each: reading the entries 128.2 s -> 9.1 s, the whole import 216.3 s -> 95.6 s, first progress after 4.5 s, and the same 380,000 rows either way. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ingest now reports progress for a Project VIC import, counting up to every entry, and _run_job moved to processing without resetting done. The bar then read n/n, 100%, before a single file was processed, while the real per-file count only arrives every 25 files. Every other place that starts a process stage already sets done=0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Before processing a single file, process() opened every video, one after another, to read four bytes and see whether it was a Snapchat LZC bundle. On an examiner's machine a 218,838-file Project VIC case sat at 0% for over four minutes on exactly that line (pipeline.py:780 > lzc.is_lzc, every 30 s snapshot), with almost no disk reads, where each open of a file was slow. An LZC bundle is named by hash with no extension, so a .mp4 or .mov is not one: only a video without a video extension is opened now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A file registered as something else that turns out to be a video (a Project VIC entry whose extension or MIME type does not say video) was decoded in a child process of its own, one per file. A 30 s snapshot of an examiner's run showed all four workers in extract_video_isolated at about 1.7 files a second. Such a file now has its hashes and kind written and joins the batched video pass, 20 to a process. An LZC bundle's video is still decoded where it is, since its bytes are not the row's file. 200 ten-frame clips named .dat, from source on Windows: 75.9 s -> 9.1 s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Processing worked on 4 files at once whatever the machine, and the video pass stopped at 4 child processes whatever was asked. On a 16-core machine a 218,838-file Project VIC case processed at about 43 files a second with most of the processor idle. Processing options on the New case and Add evidence forms gain "Files processed at once", default 4, up to the machine's logical processors (at most 32); the form shows that count from os.cpu_count(). The web job takes it as options.workers, and the video pass follows it. MANUAL.md and help.html describe it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
relink.folder_status kept its answer only until the next write, so during processing, which writes every few files, each gallery poll read every path of the case again. A 30 s snapshot of a 218,838-file Project VIC case showed all four request threads in relink._source_paths, and the gallery's count stopped updating while processing went on. CaseDB.derived_by_paths keeps the answer until a file is added or removed, or a path or source is written (path_writes), checking with one count only after a write. A repeat with nothing written still reads no row of files. Co-Authored-By: Claude Opus 5.5 <[email protected]>
OpenCV runs each call (the face detector, resizes) on threads of its own, one per processor by default, so several workers each asked for every processor and fought over them. Measured on 800 photos with face and skin screening, 8 logical processors: 4 workers 17.0 files/s, 8 workers 16.9, and 8 workers with OpenCV on one thread each 20.9 to 24.1. The setting is restored when the picture pass ends. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 30, 2026
stark4n6
pushed a commit
to stark4n6/GLEAPP
that referenced
this pull request
Nov 2, 2026
abrignoni#322 found each entry's file in one listing per folder, matched with os.path.normcase, which folds case only on Windows. On a Mac volume, and on FAT or exFAT anywhere, a name that differs from the disk's in case or in how an accented letter is composed is the same file, and Path.exists found it before abrignoni#322; the listing called it missing. A name that matches a listed one only loosely is now asked of the filesystem. A name with no loose match costs nothing more: 16,000 entries read in the same 139 to 142 ms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A large Project VIC case export looked frozen during import. On a 627 MB file of 380,000 entries, the screen sat on "Scanning sources" and nothing was written to the case for minutes. On one examiner's machine it ran past 30 minutes.
Two causes:
projectvic.iter_recordsresolved every entry's path on its own. On Windows,Path.resolve()is fiveGetFinalPathNamecalls and two link reads per path. Profiled over 30,000 entries, that was 11.8 of 14.0 s (84%).import_vicreported no progress until every entry was registered.The fix
_Locator: each folder is resolved once and listed once, and each entry is a lookup in that listing. An existing file takes the name as the disk spells it, which is whatresolve()returned on a case-insensitive volume, so rows are keyed on the same paths as before.import_vic(progress=...)callsprogress(n, what)every 2,000 entries, withwhatas "Reading Project VIC entries" and then "Registering files".ingest_sourcespasses it through, and the web job shows it in place of "Scanning sources".Measured
Windows 11, Python 3.12, on a synthetic 627 MB VIC file of 380,000 entries with a file present for each:
import_vicThe remaining time is writing the rows (
upsert_file), which this PR doesn't change. A frozen exe built from this branch imported the examiner's real export on their machine. That machine's own times weren't recorded.Behavior notes
resolve()followed it. The entry's folder is still resolved.ingest_sourcesprogress callback now has to accept an optional second argument. The two callers in the tree are the web job (updated) and the CLI (passes none).Tests
tests/test_vic_import_speed.py: paths and existence match whatresolve()gave, a differently-cased name takes the disk's spelling,files_diris listed too, and the progress calls and web job messages are covered.Also in this PR (found while testing on a 218,838-file VIC case)
2c99b5c): the ingest's entry count no longer carries into processing.fa2c7d9): every video was opened, one after another, before processing started. That held the case at 0% for minutes.0fcd7d2): a file found to be a video only during processing got a child process of its own. 200 clips named.dat: 75.9 s before, 9.1 s after.f6b582b): default 4, up to the machine's logical processors. Documented in MANUAL.md and help.html.26f6296): every gallery poll re-read all paths during processing, so the screen's count froze.2a25120): on 800 photos with screening, 8 workers went from 16.9 to 20.9–24.1 files/s.Known limit: workers are threads of one process. On a 32-processor machine, 32 ran slower than 16 (about 22 against about 60 files/s). Scaling past 16 needs processes, which will be a separate PR.
🤖 Generated with Claude Code