Skip to content

Lightroom catalog import: every original is read in full and hashed, progress stays near 0 % and Cancel waits for all of it (38k photos ≈ 25 min on a USB SSD) #832

Open

Description

@ingolfteetz

I said on #146 that I'm short on time these days, but when my own catalog sat at "14 of 38,556" for half an hour I couldn't resist. And once it went through in a few minutes, the endorphins kicked in ;-)

A data point from a real catalog, and a working branch.

Measured on main (964d933), macOS, Apple M5 Max: catalog 2026.lrcat with 38,545 photos (CR3 from an EOS R5 Mark II, Leica M11-P DNG, ORF, JPEG). 1.1 TB of originals on a USB SSD (exFAT, ~850 MB/s).

  • Reading the catalog takes 1.6 s. Everything after that is probing the originals: fs_hooks' probe reads each file whole and hashes it. That is 1.1 TB, about 22 min of reading alone at the measured rate. I didn't let it run to the end.
  • All 38k paths go to ImportJob::prepare_files as one batch. probe_all counts into a local ScanProgress, so the activity row stays at "14 of 38,556" the whole time. Its cancel flag is never set, so ✕ only takes effect after every file has been read.
  • Then apply_prepared runs on the owner thread for ~5 s: XMP parsing, Lua parsing, crs mapping and apply_partial for every photo (profiled).
  • On exFAT, find_sidecar's four is_file checks per photo cost another 8–18 s. Nearly all of them ask for files that aren't there.

What my branch does (two commits, LRC-LIB-CATALOG-IMPORT):

  • lightcraft_raw::sparse::header_plan says which byte ranges probe_info and lightcraft_meta::extract read, given a buffer of the file's length in which only some ranges are loaded. That is everything but the bulk sample data. It keeps the first chunk's coding headers, a CR3's CRX headers, QP maps and CTMD track, and a RAF's compression header. preview_plan also loads what embedded_preview needs, for raws shown from their preview. NEF, ORF and PEF (their probe looks at samples) and non-raw files are read whole.
  • The Lightroom import uses that probe (ImportOptions::headers_only). Raws probed this way get no content hash. A later import of a copy hashes same-size photos on demand (at most 16) and keeps the hash.
  • LightroomJob prepares 256 photos at a time. Probing, XMP parsing and develop mapping run on the worker, and each batch is committed as it arrives. The progress counts each original as it is probed, and ✕ stops at the next file. A cancelled import keeps what was added as one undo step, without collections. Importing again continues via the import index and then adds the collections.
  • Sidecars are looked up in one listing per folder instead of four lookups per photo.

Results:

  • Same catalog: 3 min 20 s end to end (CLI), 38,545 photos and 13 collections. User CPU dropped from ~600 s (an earlier version that read the CR3s whole) to 129 s.
  • Bytes read on the raw.pixls.us corpus: CR3 2.7 %, DNG 2.4 %, CR2 3 %, RAF 6.4 %, RW2 7 %, ARW 7.5 %, SRW 17 %. The R5 Mark II CR3s are preview-only here (CRX "adaptive QP value" unsupported), so they are read with their 3 MB JPEG track, about 15 % of the file.
  • Equivalence: for all 103 corpus raws, probe_info, extract and embedded_preview on the partly loaded buffer equal the whole file, with the skipped bytes zero and again 0xFF. 961 of my own files gave an identical ProbeInfo, the hash aside.
  • cargo xtask ci passes except export_progress_and_cancel (Flaky test: mcp e2e export_progress_and_cancel finishes before its cancel arrives (parallel export lanes + 100 ms progress throttle) #674).

Related open work: #667 changes the same file and also factors out the SQLite fixture; I'd rebase onto it. #755 reads only the RAF preview window for previews; preview_plan covers CR3 and TIFF raws too and could back that loader. After #727, NEF could join the partial read. #798 (the 1 GiB limit) is untouched.

Questions before I open a PR:

  1. Is dropping the content hash for raws probed this way acceptable (duplicate check on demand, preview cache keyed by path and size), or should hashing happen later in a background pass?
  2. A cancelled import now keeps the photos added so far, where it used to be all-or-nothing. Is that the behaviour you want?
  3. One PR, or the raw-crate sparse module first and the batched import second?
  4. @lzjtugjc, @mrpdaemon: happy to align with LR-IMP-PREVIEW-READ: a preview reads the raw's header, not the raw (56.5 MB → 5.9 MB, 10 s → 1 s over SMB) #755 and LRC-LIB-CATALOG-IMPORT: find moved root folders relative to the catalog #667, whichever order suits you.

Activity

  1. radialmonster commented on Oct 10, 2026

    @radialmonster
    Contributor

    On the R5 Mark II CR3s opening preview-only: main accepts adaptive QP values 131 to 167 (crx.rs, the "Canon CRX adaptive QP value N" error). #829 adds 168, quantisation step 44, which an R50 C-RAW at high ISO uses. If the log line for your files says adaptive QP value 168, #829 should decode them as raws, and they'd then fit your sparse plan without the 3 MB JPEG track.

    If it shows another value, could you share one file (Google Drive, or raw.pixls.us if it's a body/mode combination they don't have yet)? The two R5 Mark II C-RAW samples on raw.pixls.us decode with #829's branch.

  2. ingolfteetz commented on Oct 10, 2026

    @ingolfteetz
    ContributorAuthor

    @radialmonster thanks for looking. It isn't QP 168: my R5 Mark II files fail with out-of-range values from a misparse, e.g. Canon CRX adaptive QP value -21087. In a sample of 306 files, 174 fail on main, with values from −32401 to 32172 and none at 168, so #829 alone doesn't reach them. As you say, the two CC0 C-RAW samples on raw.pixls.us decode on main too; they just never hit the problem.

    Cause. The CRX 0x200 QP map starts with its first symbol as a 32-bit literal. Every later symbol is Rice-coded with a limited-length escape: 23 zeros, the terminating 1, then the symbol in 8 bits. That is the ITU-T T.87 escape layout for a 32-bit limit and 8-bit symbols, without its −1 offset. Main treats any 16-zero prefix as an escape followed by a 16-bit literal. That reads the first symbol the same way, which is all the R8 and R7 maps need. R5 Mark II maps (QP 150–162), though, jump by up to 12 where the Rice parameter is 0. That gives 18- to 22-zero prefixes, which are ordinary symbols, and real escapes (symbols 23 and 24).

    Tested with

    • 33,665 R5 Mark II C-RAW files from my library (version 0x200, 8480 × 5650; not shareable): every QP map decodes to the exact end of its entropy stream, QP 150–162. Both tracks of a 306-file sample do too; on main, 174 of those 306 (57 %) open as previews.
    • One of them (_A3A2841.CR3, ISO 1000), fully decoded and rendered: it matches the camera's embedded 8192 × 5464 JPEG at 100 %, with no steps in the bottom rows. The Bayer planes are 2825 rows, odd at every wavelet level.
    • raw.pixls.us 7881–7884 (R5 Mark II RAW, C-RAW, crop-mode RAW and crop-mode C-RAW; CC0, sha256 checked), added to the xtask corpus with pinned hashes. No external decoder was run on them, so those hashes guard against regressions; they are not oracle hashes.
    • The six oracle fixtures (M50, R100 and R8, RAW and C-RAW): hashes unchanged.
    • Synthetic unit tests with an 18-zero prefix and a 23-zero escape, since no public file contains them.
    • Escapes appeared in 100 of 612 maps, always at Rice parameter 0. At a larger parameter they are assumed to use the same layout (unobserved).

    What changes (ready locally, PR not opened yet):

    • crx.rs: the first QP symbol is read as a 32-bit literal, and the escape is 23 zeros plus an 8-bit symbol.
    • cr3.rs: in crop mode the R5 Mark II records its IAD1 valid area 128 px left of the image data, which starts after a strip filled with the black level. So 7883 and 7884 developed at 5112 × 3408 with a ~124 px black strip on the left. When the recommended crop overshoots the valid area, the area is now centred on the crop: 5088 × 3392, and the rank correlation with the camera JPEG goes from 0.884 to 0.993.
    • RENDER_CACHE_VERSION goes to 43, which collides with CR3: decode CRX quantisation step 44 (QP 168), Canon EOS R50 C-RAW #829's bump; whichever merges second takes 44. The other overlaps with CR3: decode CRX quantisation step 44 (QP 168), Canon EOS R50 C-RAW #829 (the same qp_map lines, tests next to each other) are textual only, and its QP-168 test passes under the new rule.
    • Docs: cr3.md, raw-parity (EOS R5 Mark II now verified, 235 models), gaps, the checklist rows and What's New.
    • For this issue: the change merges onto my lr-import-speed branch without conflicts, and sparse_corpus passes with the R5 Mark II files. They now probe as raws, so the sparse plan reads their headers and QP maps (2.6 % of the bytes for CR3 on the corpus) instead of the 3 MB JPEG track.

    cargo xtask ci passes except export_progress_and_cancel (#674).

  3. radialmonster commented on Oct 10, 2026

    @radialmonster
    Contributor

    @ingolfteetz great find on the escape layout, and thanks for checking it across that many files. Please open the PR for the QP map. It's the part nothing else covers.

    The crop-mode change is already in #754 (open, mergeable). It's the same rule: when the recommended crop overshoots the IAD1 area, the crop becomes the valid area. It gives 7883/7884 the same 5088 × 3392. You could leave cr3.rs out of your PR, or base it on #754, so the two don't conflict. I'll rebase #829 for the cache version whichever merges first.

  4. ingolfteetz commented on Oct 11, 2026

    @ingolfteetz
    ContributorAuthor

    @radialmonster thanks, done: #915 has only the QP-map fix, without cr3.rs, so it stays clear of #754. Like #829 it sets RENDER_CACHE_VERSION to 43; whichever lands second takes 44.

    On the import speed itself, the actual subject of this issue: should I open a PR for that as well? The branch is ready. If so, I'd be glad of a quick word on the questions above, especially whether you'd prefer one PR, or the lightcraft_raw::sparse module first and the batched import second.

  5. radialmonster commented on Oct 11, 2026

    @radialmonster
    Contributor

    @ingolfteetz thanks for #915. I'm a contributor, not a maintainer, so the maintainers have the final say. Here's my view:

    1. I'd do two PRs: lightcraft_raw::sparse first, then the batched import on top. The sparse module is pure and checked by your equivalence test (same probe_info / extract / embedded_preview as the whole file, with skipped bytes as 0 and 0xFF), so it can be reviewed and merged by itself. LR-IMP-PREVIEW-READ: a preview reads the raw's header, not the raw (56.5 MB → 5.9 MB, 10 s → 1 s over SMB) #755 could also use preview_plan once it's in. The import PR then only covers behaviour (batches, progress, cancel, sidecar listing) and can rebase onto LRC-LIB-CATALOG-IMPORT: find moved root folders relative to the catalog #667.

    2. Without a hash, two things on main get weaker. I'd note both in the PR:

      • Find Missing Photos (cmd/missing.rs) relinks a renamed file by size plus content_hash. A photo with no hash only matches by name and size.
      • content_op (cmd/convert.rs) compares info.content_hash with the stored one, so the first full probe of such a photo counts as a content change and writes a SetContent op. Check that this doesn't add an undo step or reset previews on a normal refresh.

      A low-priority background pass that fills in missing hashes later would fix both, and could be a follow-up.

    3. Keeping what was added, as one undo step, and continuing on the next import, sounds right to me for a 38k-photo catalog. All-or-nothing makes a late cancel throw away 20 minutes of work.

  6. ingolfteetz commented on Oct 11, 2026

    @ingolfteetz
    ContributorAuthor

    @radialmonster thanks, that's the split I went with: #961 is step 1, lightcraft_raw::sparse on its own, with no behaviour change and the equivalence test (skipped bytes as 0 and as 0xFF on the whole corpus).

    Step 2, the batched import, follows on top of it and on #667. Two things from your list will be in it:

    • Reload: a photo with no stored hash won't count as changed just because its first full probe has one. No "Reload Changed Files" step and no preview reset when the file is the same.
    • Find Missing Photos: the PR will say that such photos match by name and size only, until something fills in their hash. A low-priority background pass for that fits well as a follow-up.

    Good to hear the cancel behaviour makes sense to you. I'll wait for the maintainers on all three before step 2.

  7. lzjtugjc commented on Oct 11, 2026

    @lzjtugjc
    Contributor

    Thanks — with #961 in (batch 31), I picked up the preview side @radialmonster mentioned ("#755 could also use preview_plan once it's in"). #755 landed in the same batch (e4a248c9) and it is RAF-only: preview_window parses the RAF header pointer itself, so CR3, TIFF raws whose preview pointer sits past the 4 KiB prefix, and the scan-based formats still fall back to reading the whole file.

    I'd like to close that by asking preview_plan for the ranges instead of parsing a format by hand, so every format the plan can describe reads a fraction of the file — a CR3's JPEG track, a TIFF raw's preview strips (NEF / ARW / CR2 / DNG / RW2 / 3FR …). It would also drop the "pointer past the prefix" limitation #755 documents, and the duplicated RAF header parse (sparse::raf_plan already covers those fields).

    The guarantee the loader needs is the one your module was built on: with preview = true the plan reaches Ready, and embedded_preview on the partly loaded buffer equals the whole file's with the skipped bytes both 0 and 0xFF (crates/raw/tests/sparse_corpus.rs). One gap I'd fix in the same PR: those preview assertions sit inside the header_plan == Ready branch, so for NEF / ORF / PEF — whose header probe reads samples and returns Whole — the preview plan is never exercised today. Your R5 Mark II numbers are the same shape as the RAF ones #755 measured: a ~3 MB JPEG track is read out of the whole file, and today every unedited CR3 thumbnail still pays for the whole file (Canon is the largest bucket in the project's own gap ranking).

    Two questions before I write it:

    1. Memory vs I/O. preview_plan is asked about a buffer of the file's full length with only loaded holding bytes. Reusing that as-is means a full-length (zero-filled) buffer: only the planned ranges are read and only their pages are touched, so RSS stays near the ranges, but the allocation is the file's length. The loader today holds the whole file and counts len * 2 at the memory gate. Do you prefer (a) keep the sparse buffer and count the planned ranges at the gate, or (b) use the plan only to discover ranges and read them into a compact buffer (which means assembling multi-strip previews)?

    2. Overlap with step 2. Step 2 is the import side (headers_only, batches, progress, cancel); this is the display side — the PreviewLoader the grid, the loupe and the face scan go through. I read that as non-overlapping, but if you'd rather carry the loader change in your branch, or want it based on LRC-LIB-CATALOG-IMPORT: find moved root folders relative to the catalog #667 first, say so and I'll stay out.

  8. ingolfteetz commented on Oct 11, 2026

    @ingolfteetz
    ContributorAuthor

    @lzjtugjc sounds like a good use of it to me, though the maintainers have the final say, of course. From my side I don't see an overlap with step 2.

    1. Memory vs I/O: I'd lean towards (a), keeping the sparse buffer. Every reader works on absolute offsets (IFD offsets, box positions, chunk offsets), so a compact buffer would need a translation layer through all of them, and the equivalence test would no longer cover what the loader reads. Two observations from my import runs, in case they help:
      • For TIFF-based files, counting only the planned ranges at the gate might be too optimistic for now. lightcraft_meta::embedded copies the whole buffer for them (exif: Some(bytes.to_vec())), and the preview path reaches it through extract (preview_orientation), so every page gets touched and duplicated. For CR3 and RAF only the planned ranges are touched. Borrowing the EXIF block instead of copying it might be worth a look, since it would also save a full copy on every raw probe today.
      • On macOS the freed full-length buffers stayed resident as "Malloc Large (empty)": 2–2.5 GB during my 38k-photo import with 8 probe threads, and memory::release() after each file didn't shrink it. It's allocator cache rather than held memory, but it shows in RSS.
    2. Overlap: step 2 also touches files.rs, but only next to fs_hooks: fs_header_probe, a partial-read loop (probe_partial: a prefix, then the ranges the plan names, up to 16 rounds, giving up past 60 % of the file) and embedded_preview_size (JPEG header first, decode as fallback). If the loader ends up needing the same loop, I'd be glad to factor it into a shared helper in whichever PR lands second.

    On the test gap: good catch. Running the preview assertions whenever preview_plan reaches Ready, independent of the header plan, makes sense to me. One thing to be aware of: today preview_plan returns Whole for NEF, ORF and PEF anyway, because they share the header plan's early exit for formats whose header probe reads samples. I don't think previews need that exit, so lifting it in preview mode might bring at least NEF and PEF in (ORF's raw IFD may first need to be recognised as raw). The corpus test would tell.

  9. lzjtugjc commented on Oct 11, 2026

    @lzjtugjc
    Contributor

    PR is up: #1020. planned_preview in crates/engine/src/files.rs reads the ranges preview_plan names, and the guards we discussed keep the whole-file path: Whole, a plan that wants more than 60 % of the file, a container that declares Adobe RGB (the whole-file path applies it; a JPEG-only decode assumes sRGB), and an orientation only the whole file can show when the preview JPEG carries none.

    The corpus test now asks preview_plan for every file, so lifting the NEF/PEF exit in preview mode would be caught either way if you want to try it in step 2 — and I'm happy to fold the read loop into a shared helper in whichever of the two PRs lands second.

  10. Eliksir67 commented on Oct 11, 2026

    @Eliksir67

    Hello, here is my contribution to this topic, based on my own tests:

    Investigated and written with Claude Code.

    The normal import dialog has the same cost, before the user sees anything. library.importPreview (import::scan_with → probe_all) runs the file probe from fs_hooks (crates/engine/src/files.rs), which reads every file whole (std::fs::read) to hash it, on up to 8 threads at once (workers, import.rs). The dialog's thumbnails then go through fs_preview_loader, which reads each raw whole again to find its embedded preview, unless the bytes are still cached.

    Measured with lightcraft-cli run --library <empty> library.importPreview paths=[<folder>] (v0.6.0, Linux), page cache dropped first: 250 Canon raws, 6.9 GB, on an internal SATA hard disk (NTFS through ntfs-3g): 166 s before any candidate is returned. Reading the same files cold with cat or dd takes about 144 s (about 48 MB/s on this disk), so the scan already runs close to the disk's speed: the wait is the full read of every file itself. On an SSD with the files in the page cache, the same scan of 15 raws (491 MB) takes 0.19 s.

    Edit: an earlier version of this comment quoted a 41.7 s sequential read and suggested reading one file at a time on hard disks; that read was not cold (part of the files was still in the page cache). With the cache dropped, one reader at a time only brought the scan from 166 s to 145 s here, so that suggestion is withdrawn.

    Now that header_plan is on main (#961), could step 2's partial probe and on-demand duplicate check also apply to library.importPreview and the normal import (ImportJob::prepare_files), not only to headers_only Lightroom catalog imports? The preview read from #1020 would cover the dialog's thumbnails. With the share of bytes measured in the issue body (CR2 3 %, CR3 2.7 %), the scan above would read about 200 MB instead of 6.9 GB.

    What the full content hash is used for today, as far as I can see, in case it helps scope step 2:

    • duplicates on import (by_hash in import.rs);
    • checking a copy or move into the library (copy_into), which reads the whole file anyway and could hash it while copying;
    • matching moved or renamed files in folder sync (sync.rs);
    • the thumbnail cache key (media::content_key); without a hash it falls back to file:path:size, so a moved file loses its cached thumbnails.

    One thought on the duplicate check, in case it is useful: comparing file sizes first, then a partial hash only for files of the same size, and the full hash only when those match, would keep full reads for true duplicates. The partial hash could perhaps cover the ranges header_plan (#961) already reads, plus the end of the file, so it would cost little more than the header read itself.

    I hope this is useful. Many thanks to the developers!

  11. youyoulyz commented on Oct 13, 2026

    @youyoulyz

    Adding a network-share data point, since the SMB worst case is considerably worse than the exFAT one:

    • macOS 15.7.7, 0.7.1, sources + library on an smbfs volume over wired 2.5GbE (~180 MB/s measured with netstat).
    • Catalog: ~8,725 photos, mostly 40–50 MB DNGs (~390 GB). Stuck at "14 of 8725" for 30+ min while every original was full-read + hashed over the network; cancel mid-probe doesn't take effect, same as you describe.
    • sample(1) shows the same stack: probe_all spawns 8 workers, each fs_hooks → fs::read of the whole file → siphash128; two parked in WorkGate at the same time. lsof 10 s apart shows a fresh set of open DNGs each time — I/O-bound, not hung.

    headers_only should cut this to low single-digit % of bytes read, like #755 did for previews (56.5 MB → 5.9 MB, 10 s → 1 s over SMB). Happy to run a test build of the branch against this catalog.

  12. Nehle commented on Oct 13, 2026

    @Nehle

    I can confirm this is a significant issue for large NAS-based Lightroom libraries.

    I'm currently importing a Lightroom Classic catalog with 112,622 photos, referencing a photo archive of approximately 2.6 TB on a Synology NAS over SMB, using LightCraft 0.6.0 on Windows.

    The import has been running for more than two days, with sustained network reads of approximately 300 Mbps (30–40 MB/s from the NAS).

    The progress indicator initially remained at 14 of 14 for several hours before changing to 14 of 112622. It has not advanced since, despite continuous network activity.

    I haven't seen any changes committed to the destination LightCraft catalog yet.

    I've looked through the proposed optimization and agree that sparse RAW probing, batching and proper progress reporting would be a major improvement.

    I'd also suggest considering a metadata-first migration mode in the longer term. For an existing Lightroom catalog, it should be possible to import the photo records, collections, ratings and metadata without immediately accessing every original file, then perform verification and hashing as optional background work.

    Happy to provide additional diagnostics or test the optimized importer against this larger

  13. ingolfteetz commented on Oct 14, 2026

    @ingolfteetz
    ContributorAuthor

    Step 2 is up: #1735. It builds on #961 and on #1024 (@rwoldberg's read progress and cancel are kept).

    • Originals are described from their headers (fs_header_probe); the read loop is now shared with LR-IMP-PREVIEW-READ: a CR3 or a TIFF raw's preview is read from the plan's ranges #1020's planned_preview (read_planned), as discussed, @lzjtugjc.
    • Photos are added batch by batch (256 at a time) while the rest is read, so a cancel or a crash keeps what was added, and importing again continues. XMP parsing and develop mapping run off the UI thread.
    • On my catalog: 2 min 2 s for 38,545 photos with 1.1 TB of originals on a USB SSD.

    @youyoulyz @Nehle thanks for the numbers from SMB; they make the case better than mine. If you'd like to try it before it's reviewed, the branch is lr-catalog-import-batches in ingolfteetz/lightcraft:

    git clone -b lr-catalog-import-batches https://github.com/ingolfteetz/lightcraft
    cd lightcraft
    cargo run --release -p lightcraft
    

    A run against a network share would be the most useful data point, since I could only measure a local USB drive. @Nehle, an import that is already running can't switch over, but with this branch a cancelled import keeps the photos it added. The metadata-first idea sounds good to me as a later step: this PR still reads each original's headers, but nothing more.

    @Eliksir67 thanks for measuring the normal import; I agree the same approach could help there. I'd keep it out of #1735, which only changes the Lightroom import and already overlaps with #1014 and #842, and see it as a possible step 3, if the maintainers want it:

    • Add-mode imports and the import dialog's scan would probe from the headers, as the catalog import now does.
    • Duplicates along the lines you suggest: size first, then a hash of the planned ranges plus the file's tail, and the full hash only for candidates that still match.
    • Copy and Move could hash while copying (copy_into reads every byte anyway), so they'd keep a full hash without an extra read.
    • Folder sync would match by size and dimensions where there is no hash, as it already does for catalog photos.

    The parallel probe on hard disks seems worth its own look; with header reads the reads get small, so the seeks matter even more there. I'd be glad to take step 3 on once step 2 is in, unless someone else would like to.

  14. youyoulyz commented on Oct 14, 2026

    @youyoulyz

    A network-share run of #1735, as requested (same share as the SMB numbers I quoted):

    • macOS 15.7.7, M4; sources on a local NAS over smbfs, wired 2.5GbE. Whole-file sequential reads on this share measure ~180 MB/s (the 0.7.1 full-read import sustained that while probing).
    • Catalog: 8,711 photos (135 already missing on the NAS), mostly 40–50 MB DNGs, ~390 GB of originals.
    • Branch lr-catalog-import-batches (0848ef2): lightcraft-cli run --library <fresh local library> library.importLightroom path=…

    Results:

    • Completes end-to-end, exit 0: 8,576 imported + 135 failed (the files missing on the NAS; they are still recorded, the library ends at 8,711 photos), 7 collections, 7 warnings. Batches commit while the run progresses — catalog.log grows throughout and is compacted to a snapshot at the end. A mid-run sample(1) shows exactly the new path: LightroomJob::next_batch → probe_all → fs_header_probe → read_planned.
    • Wall time 73.9 min; ~65 GB read over the network (~17 % of the archive, ~7.5 MB/file). CPU is only ~6 % (user+sys 366 s of 4,436 s) — wait-bound, not compute-bound. Effective throughput settled at ~15 MB/s against this share's ~180 MB/s sequential. So here the small planned reads trade bytes for round trips/seeks: 6× fewer bytes, but roughly 2× the old full-read path's estimated transfer time on this share (~36 min at 180 MB/s — it couldn't have finished anyway because of the Library on an SMB share: the catalog files are written where macOS can't fully flush them #1409 write bug, but that's the comparison).

    @Eliksir67's point about hard disks applies directly: with small reads, seeks and round trips dominate. Coalescing the planned ranges per file, or a latency-aware read plan for network volumes, could make this a real win here too — happy to re-run anything you'd like to try.

    Source catalog and originals verified untouched (md5s + mtimes before/after); the import is add-in-place.

  15. added a commit that references this issue on Oct 15, 2026
  16. Nehle commented on Oct 15, 2026

    @Nehle

    Follow-up on my earlier SMB test: I've now completed an import using the lr-catalog-import-batches branch from PR #1735.

    Environment

    • Windows, LightCraft development build identifying itself as 0.8.0
    • Synology NAS over SMB, with a local LightCraft library
    • Lightroom Classic catalog containing 112,622 photos
    • Original photo archive: approximately 2.6 TB
    • Fresh LightCraft library created before the import

    Observations

    The new importer is a substantial usability improvement over 0.6.0:

    • Progress updates continuously instead of remaining stuck at 14 of 112622.
    • Photos are committed incrementally while importing.
    • Network reads are bursty, typically around 10 MB/s, rather than the sustained 30–40 MB/s observed with 0.6.0.
    • Throughput varied, but I observed roughly 4 photos/s over one 20-minute interval.
    • The import completed overnight. Unfortunately, I didn't capture exact start/end timestamps, so I can't provide a reliable wall-clock benchmark.

    One correctness issue: None of my Lightroom collections appeared after import.

    I've verified directly against the source .lrcat SQLite database that it contains 51 collection records, 46 of which have systemOnly = 0 (30 ordinary collections, 12 smart collections, 2 groups and 2 print collections). The destination library contains no corresponding albums.

    I observed the same missing-collections behavior with the original 0.6.0 importer, so this appears unrelated to the optimization in #1735.

    I'll report the collection issue separately with the available diagnostics.

    Overall, the new importer is a major improvement, particularly the incremental commits and meaningful progress reporting. Thanks for the work on this!

  17. ingolfteetz commented on Oct 16, 2026

    @ingolfteetz
    ContributorAuthor

    @youyoulyz @Nehle thank you both for running the branch on real network shares. That's exactly what I couldn't measure here.

    @youyoulyz, SMB throughput. You're right: on your share the many small reads cost more in round trips than they save in bytes. Two things stand out:

    • ~7.5 MB per file is more than I'd expect for DNGs. On the raw.pixls.us DNGs the header plan reads 2.4 % of each file, which would be about 1 MB of a 45 MB DNG. So I suspect part of your files fall back to a whole read (a plan that would read more than 60 % of the file, or a DNG the reader can't describe from its headers). Which software wrote them: the camera, Adobe DNG Converter, or something else? If you could share one or two (privately is fine), I'd check which path they take.
    • read_planned issues one seek and read per range, over up to 16 rounds, which is the worst case for SMB latency. Merging ranges that sit close together into one read, and a larger first read than the current 512 KB, should cut the round trips without reading much more. I'd do that as a small follow-up rather than in LRC-LIB-CATALOG-IMPORT: Lightroom catalogs import in batches from the originals' headers (step 2 of #832) #1735, unless the maintainers prefer it in there. I'll ping you when there's something to re-run.

    @Nehle, missing collections. Glad the import itself went through. One thing to check: collections are only added once every batch has arrived. If the import ended with an error or was cancelled, the photos stay but the collections don't. Did the result dialog say "Lightroom import complete" or "cancelled"/an error, and did it list any warnings? If it stopped early, importing the same catalog again into the same library should skip the photos already there and add the collections at the end. If the dialog said complete and there are still no albums, that's a bug I'd like to look at; your separate issue would be the right place for it.

  18. ingolfteetz commented on Oct 16, 2026

    @ingolfteetz
    ContributorAuthor

    @youyoulyz the follow-up is up as #2051 (stacked on #1735). Counting reads per file showed the main cause: on tiled DNGs from Adobe's converter, the plan asked for the one-byte pad after every odd-length tile, so it made 49 to 241 separate reads per file. On the raw.pixls.us DNGs that is now 2 reads, and RAF files go from 7 reads to 4. Each read is now at least 64 KiB, and ranges that sit close together are read as one.

    If you have time for another run on your share, the branch is lr-import-coalesce-reads in ingolfteetz/lightcraft:

    git clone -b lr-import-coalesce-reads https://github.com/ingolfteetz/lightcraft
    cd lightcraft
    cargo run --release -p lightcraft-cli -- run --library <fresh local library> library.importLightroom path=…
    

    Wall time and bytes read, as in your last run, would show whether this closes the gap. If the ~7.5 MB per file stays, those DNGs probably take another path, and one or two of them would help me find out which.

  19. youyoulyz commented on Oct 17, 2026

    @youyoulyz

    Re-ran on my share with #2051 (lr-import-coalesce-reads, 6e1880c) — same NAS, same catalog, fresh local library, same measurement method:

    #1735 #2051
    wall time 73.9 min 3 min 39 s
    network read ~64.9 GB ~15.5 GB
    per file ~7.5 MB ~1.8 MB
    CPU (user+sys / wall) ~8 % ~45 %

    So: 20× faster and 4× fewer bytes — the round-trip cost is gone and the run is now CPU-bound, not wait-bound (mid-run throughput 46 MB/s, was ~12–15 MB/s). A mid-run stack still shows next_batch → probe_all → fs_header_probe. Import result: 8,711 photos, 7 collections. (failed is 0 this time — the 135 missing-file photos are now recorded rather than reported, a behaviour difference from main since my #1735 run, not from your PR.)

    DNG origin: Sony ILCE-7RM3 (A7R III), converted to DNG by Lightroom Classic's "Convert to DNG" at import — Adobe-tiled DNGs, matching your diagnosis. Per-file bytes are now much closer to your 2.4 % estimate; if the remaining ~0.7 MB/file above it still matters, I can ask about sharing one or two samples to check whether a minority of files still takes a whole read.

    Either way, this closes the gap — thanks for the fast turnaround.

  20. Eliksir67 commented on Oct 17, 2026

    @Eliksir67

    Hello, here are the results of #2051 on a slower setup, in case they help.

    Investigated and written with Claude Code.

    • Linux, CLI library.importLightroom from lr-import-coalesce-reads (6e1880c), fresh local library.
    • Originals on a Synology DS414j (4 hard disks, 1 GbE) over SMB 3.0.
    • Catalog made on Windows: 29,506 photos (12,328 files, CR2 and CR3, the rest virtual copies), 182 collections, 400.6 GB of originals.

    Results:

    • Completed, exit 0: 29,506 imported, 0 failed, 1 missing (a file not on the share), 182 collections, 8 warnings (smart collections imported as their current membership, recovery archive over 32 MiB skipped).
    • Wall time 12 min 11 s; 18.0 GB read from the share (4.5 % of the originals, about 1.5 MB per file), about 25 MB/s on average, the process using around one CPU core.
    • Reading the 400 GB whole would take at least an hour on this link, so the gain seems clear here too. Per file it is slower than @youyoulyz's run (about 17 files/s against 40), which would fit a NAS where each file costs disk seeks more than bandwidth.

    One thing that came up: the Lightroom catalog records the originals under E:/Raw, which doesn't exist on Linux, so every photo would have been imported as missing. For this test the import was run from a folder holding E:/Raw as a link to the share, since the recorded Windows path seems to be resolved against the current folder. Would it make sense, before the import starts, to list the root folders that can't be found and ask where each one is now? A catalog usually has few root folders, and the photos would then be linked from the start (and read from their headers) rather than relinked afterwards. #1116 seems related, but applies after the import.

    Thanks for the work on this import, the difference is very visible on this NAS.

  21. Nehle commented on Oct 17, 2026

    @Nehle

    Follow-up with results from a full-scale benchmark of the optimized Lightroom importer in #2051.

    Test environment

    • OS: Windows

    • Build: LightCraft 0.8.0 development branch, commit 6e1880ca337ec2dda6d7560066ab841f374880eb

    • Importer: lightcraft-cli, running library.importLightroom against a fresh library

    • Source catalog: 112,622 Lightroom photo records

    • Photo archive: Approximately 2.6 TB on a Synology DS418j with mechanical HDDs

    • Connection: NAS on gigabit Ethernet; PC on Wi-Fi 6 (780 Mbps negotiated link rate)

    • Destination library: Local SSD

    Benchmark results

    Metric Result
    Total execution time 5h 20m 16s
    Wi-Fi received 264,064 MiB (~258 GiB)
    Average Wi-Fi receive rate 13.7 MiB/s
    Observed traffic peaks Approximately 350 Mbps
    Typical active bursts Approximately 150–250 Mbps

    The network figures were captured from Windows network-adapter byte counters sampled every two seconds. They include all traffic on the adapter, not exclusively LightCraft's SMB traffic, so they should be treated as approximate upper bounds on LightCraft's network consumption.

    Network usage was highly bursty, with extended periods of near-zero traffic between reads.

    Compared with 0.6.0, the behavior is substantially better: the earlier importer performed sustained reads around 30–40 MB/s, provided little meaningful progress, and took more than two days in my previous test.

    However, I don't have reliable end-to-end timing for the previous branches, so I can't quantify the speedup accurately.

    Import result: finalization failed

    The CLI eventually returned:

    {
      "command": "library.importLightroom",
      "error": "invalid: parent must be an existing folder",
      "ok": false
    }

    The photo-processing phase persisted its results, but none of the Lightroom collections were imported.

    This is the same missing-collections behavior I observed with both 0.6.0 and #1735, but the CLI finally exposed a concrete error.

    I've opened a separate issue for the collection-finalization failure: #2165.

    The error appears to originate in album parent validation during Lightroom collection creation, rather than the optimized RAW-reading pipeline.

    Benchmarking observations

    I also monitored import progress by periodically inspecting the destination catalog's persisted state.

    A few observations that may be useful:

    • The importer persisted photo additions incrementally, but the observable count often advanced in jumps of approximately 2,560 photos (10 × 256).

    • Because progress was committed in relatively large increments, short-window throughput estimates were misleading.

    • A rolling average over several commit intervals gave a more stable ETA.

    • The CLI import command didn't provide useful intermediate progress output, so monitoring required inspecting the destination library separately.

    • A separate library.inspectLightroom invocation appeared to stall after reading approximately 1.06 GB from the source catalog, with no further CPU or disk activity observed. I bypassed inspection for the successful benchmark run.

    A structured CLI progress stream would make future benchmarking significantly easier, especially for large catalogs.

    Overall

    The optimization is a substantial improvement in network efficiency and import behavior for this 112k-photo catalog on a relatively modest NAS.

    The remaining issue is correctness: after several hours of photo processing, collection finalization fails, and no Lightroom identity index is persisted.

    I'm happy to provide the benchmark CSVs, CLI logs, or additional diagnostics if useful. Thanks for the continued work on these optimizations!

  22. ingolfteetz commented on Oct 18, 2026

    @ingolfteetz
    ContributorAuthor

    Thanks @youyoulyz, @Eliksir67 and @Nehle for running #2051 on your NAS setups. Three different setups make the picture much clearer:

    photos originals read time
    @youyoulyz, SMB, 2.5 GbE 8,711 (DNG) ~390 GB ~15.5 GB 3 min 39 s (#1735: 73.9 min)
    @Eliksir67, DS414j HDDs, 1 GbE 29,506 (CR2/CR3) 400.6 GB 18.0 GB 12 min 11 s
    @Nehle, DS418j HDDs, Wi-Fi 6 112,622 ~2.6 TB ≤ 258 GiB 5 h 20 min (0.6.0: > 2 days)

    I've added them to #2051's description.

    @youyoulyz, no need for samples, I think: 1.8 MB of a ~45 MB DNG is about 4 %, close to what the corpus shows.

    @Eliksir67, listing the catalog's root folders that can't be found before the import starts, and asking where each one is now, sounds very useful, especially for a catalog moved from Windows to Linux or macOS. I'd see it as its own step after #1735, and #1116 might be a natural home for it. That's up to the maintainers.

    @Nehle, thanks for tracking down the collections error. I'll follow up in #2165.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions