Repository navigation
PERF-SYNC: a Synchronize Folder scan reads off the folder's listing whether a photo and its sidecar are there - #1602
Merged
Conversation
…hether a photo and its sidecar are there The scan asked the disk about every library photo in the folder: is its file there, and has it a sidecar under any of four names. On a network share each question is a round trip, and the scan had just listed the folder. Measured on a hard disk over SMB, for unchanged folders of 1,600 to 2,400 photos: 4.6 to 7.1 s of questions after a listing of 4 to 5 s. - The walk hands each folder's listing over (`walk::files_in_noting`: every entry's name and kind, hidden ones too, and whether that is all of them). The scan walks the folder once, then checks the photos beside the probing of new files. - `sync::Listing` answers "is it there" / "is it a file" where that holds on any file system: a name the folder lists is there; a plain ASCII name is not there when the folder was listed to its end, all its names are ASCII and none is that name in another case. Everything else is asked of the disk as before (a link, a name Windows reads another way, a folder that was not walked, and every name not listed in a folder that holds a name outside ASCII). Now under 0.05 s for those folders. Two things differ on purpose: a file the folder lists is there though it can't be opened by its path (a folder that may be listed but not searched, an over-long path), where such photos were listed as missing; and the answers are the folder as the walk saw it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
force-pushed
the
sync-from-listing
branch
from
October 14, 2026 12:12
499d6f6 to
540a281
Compare
Member
|
Thank you @nledford! This landed on main in integration batch 40 (#1867), rebased onto main after the previous batches. If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there. |
pehonnet
pushed a commit
to pehonnet/lightcraft
that referenced
this pull request
Oct 15, 2026
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.
Its base, #1583, is now in
main: after the rebase ontomain(integration batch 35,a4b53b28) this pull request is its one commit,540a281c("PERF-SYNC: …"). The rebase met onlydocs/whats-new.md(both entries kept); the code applied unchanged.Problem
A Synchronize Folder scan of a folder on a network share is slow though nothing in the folder changed. For every photo of the library in the folder it asks the disk whether the file is there and whether it has a sidecar under any of four names (
IMG.xmp,IMG.XMP,IMG.jpg.xmp,IMG.jpg.XMP). Each question is a round trip, and the scan has just listed the folder to look for new files: the listing holds every one of those answers.Change
Engine only (
crates/engine/src/walk.rs,sync.rs,import.rs,sidecar.rs).walk::files_in_notingcalls back with each folder it reads: the name and kind of every entry (hidden ones too) and whether that is all of them (not when the walk stopped inside the folder, or an entry could not be read).files_inis the same walk without the callback and returns what it returned.sync::scan_withwalks the folder once (import::expand_noting), then checks the library's photos beside the probing of the new files (import::scan_files, the body ofimport::scan_withafter its walk). Before, the checks ran beside the walk.sync::Listinganswers where it is sure, and the disk is asked otherwise.~, no:, no dot or space at its end), and no name in the folder is that name in another case.aux.jpg,NUL,COM1…), a path that does not end in its file's name, a folder the walk did not list.Not in this PR:
ẞisSS; how accents are written; marks that are passed over). In such a folder the scan saves less, and its checks now start after the listing, so it can take longer than before by up to the time of the listing.Listingholds every name of the tree until the scan ends (bounded by the walk's limit of 1,000,000 entries).How it was checked
cargo xtask cion this branch: run gate by gate, see belowNumbers.
cargo run --release -p lightcraft-engine --example sync_scan_bench -- <folder>(added here: it makes a library of the folder's own files, so nothing has changed, and times the scan; it reads the folder and writes nothing there). An SMB share on a hard disk over a 2.5 Gb LAN, macOS client, folders of JPEGs with ASCII names and no subfolders, each not listed for several minutes before its run:That is about 3 ms a photo before. "Before" is #1583's commit; before and after were run on different folders of each pair and then swapped, because a second scan of a folder just scanned is answered from the client's cache whichever code runs (both show 0.0 s). The scan's own walk of the folder came right after the benchmark's listing, so it is not in these scan times; in the app it is, and it is unchanged.
On the same share: listing costs about 2 ms an entry and is barely cached between passes (193,000 entries: 521 s, then 455 s; with eight folders listed at once, 389 s).
Tests (3 new):
the_listing_answers_only_what_it_is_sure_of: a table of 45 names against a listing: listed, not listed, another case, a link, a folder cut short or not walked, names outside ASCII (among themSTRAẞE.jpgasked about asstrasse.jpg), Windows' device names and name forms, paths that do not end in a file's name, a name that is no text.a_check_from_the_listing_is_the_check_from_the_disk: a folder on disk with photos that are there or gone and sidecars under every name a sidecar can have; each photo's check with the listing equals its check from the disk, under both namings. The disk is asked 9 times with the listing where it was asked 20 times (the folder holds a name outside ASCII), and not once for a subfolder whose names are all ASCII.a_walk_notes_each_folders_listing: the walk is the same walk noted or not; a folder's listing holds every entry with its kind (a hidden file, a link as neither file nor folder) and says when it is not all of the folder.Run on this branch (before the rebase):
cargo fmt --all --check;cargo clippy --workspace --all-targets -- -D warnings(with-A clippy::chunks_exact_to_as_chunks, which rustc 1.99 raises incrates/pipelineonmainhere);cargo xtask parity,layers,assets;cargo testforlightcraft-catalog,lightcraft-engine,lightcraft-ui-egui,lightcraft,lightcraft-mcpandlightcraft-cli(1,979 tests pass). Not run:cargo xtask wasm, the other crates' tests, and nothing on Windows or Linux.After the rebase onto
a4b53b28:cargo fmt --all --check; clippy-D warningsforlightcraft-engine, all targets (same allowance);cargo xtask parity,layers,assets;cargo test -p lightcraft-engine(855 pass, 6 ignored): all pass. Not rerun after the rebase: the other crates' tests and clippy,cargo xtask wasm, the benchmark.Reviews. Two independent reviews, and what they changed:
STRAẞE.jpgis found asstrasse.jpgon APFS, and the narrowed rule said "not there". I took the narrowing out again: the rule is the one the first review tested, with Windows' device names and name forms added.Merging
sidecar.rs,sync.rsandcmd/query.rs(who reads a shared stem sidecar); not checked for textual conflicts. My own Synchronize Folder: the scan can continue in the background #1124 (in batch Integration batch 34: CI on three platforms, HEIC/AVIF metadata, Dehaze V3, 35 reviewed contributor PRs #1441), Synchronize Folder: a Read row for the new photos, and dialogs remember theirs (stacked on #1095) #1127 and LRC-LIB-LIBFOLDERS: catalog queries and streamed file hashing for locating a folder (part 1 of 3) #1122 changesync.rs; whichever lands second needs a small merge inscan_with, which I will do.r--, or a share set up so), or a path longer than the system takes. Such photos were listed as missing.unsafe, build scripts, network access, spawned processes, deleted files, CI orxtaskgate changes: none. One new example (sync_scan_bench).Checklist
docs/whats-new.mdhas its entry. No row ofdocs/parity-checklist.mddescribes this🤖 Generated with Claude Code