Repository navigation
Description
Summary
Proposal for discussion. There's no PR with it, because this is a design decision for the maintainers.
RENDER_CACHE_VERSION (crates/engine/src/media.rs:65, now 61) is one number covering every rendered thumbnail and view render. It is part of every disk and memory cache key (media.rs:1100, :1142, :1230). The rule is "bump when the pipeline's output changes". In practice:
- It changes about five times a day. 59 commits on
mainchanged the constant between 2026-09-30 and 2026-10-11. By task id: 21LR-IMP-FORMATS(one decoder each), 10LR-PROF-CAMERACOLOR, 4 eachLR-IMP-CAMERA-COVERAGE,LR-EDIT-OPTICS-PROFILEandLR-EDIT-LIGHT-HIGHLIGHTS, and a handful of milestone commits (git log origin/main -G'RENDER_CACHE_VERSION: u64 =' -- crates/engine/src/media.rs). - Every bump throws away every user's whole render cache. A fix to Canon CR3 quantization (
5a975d0d) or Kodak DCS520C TIFFs (ea777710) re-renders every JPEG, NEF, ARW and HEIC thumbnail in every library on the next launch. That is a full-library decode and render: minutes to hours on big libraries, on battery, right after an update. - Parallel PRs collide on the number. Every open PR that touches decoding or rendering edits the same line, so they conflict textually. Worse, two PRs can land with the same new number and silently share a version. Contributors coordinate by hand in comments ("
RENDER_CACHE_VERSIONgoes 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" on 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; again on LR-IMP-FORMATS: decode Canon EOS R5 Mark II C-RAW (CRX QP-map first literal and escape) #915 and CR3: decode CRX quantisation step 44 (QP 168), Canon EOS R50 C-RAW #829). Improve RAW normalization, native lens corrections and mask integrity #979 says "Invalidate old rendered previews (version 51)" while main is at 61.
What is already versioned separately
camera_profiles::cache_key()(camera_profiles.rs:156): changes with the profiles folder's contents.camera_preview::LOOK_VERSION(camera_preview.rs:~22): the camera-look fit, for smart-preview proxies.DevelopSettings::process(docs/process-versions.md): deliberate look changes ship as a new process, and the process is inside the settings hash already. So a photo on V1 keeps its cache when V2 lands, without any global bump.
So part of what RENDER_CACHE_VERSION does is already done more precisely elsewhere. What's left is mostly decoder and source changes (per format, often per camera) and bug fixes that land in place (CPU/GPU mismatch, NaN, wrong crop).
Proposal
Replace the single constant with a key made of per-component versions. Each one is bumped only by changes to that component:
- Decoder version per format family. For example a
decoder_version(format) -> u32table inlightcraft-raw/lightcraft-codecs(cr3,nef,arw,raf,dng,jpeg,heic,jxl, …), next to the decoders it describes. The render key uses the version of the photo's own format, so a CR3 fix invalidates only CR3 renders. Where a fix is narrower still (one camera model), the table can take the model too, but per-format already removes most of the churn. - Pipeline version for in-place fixes. A small
PIPELINE_FIX_VERSIONinlightcraft-pipeline, for the bug fixes thatdocs/process-versions.mdallows to land without a new process. Process-level look changes need nothing: the process is in the settings hash. - Camera colour: keep
camera_profiles::cache_key(), and addLOOK_VERSIONto the render key where the fitted look feeds renders (today it only drives proxy rebuilds). - Optics / lens data: a version for the embedded-lens and lens-profile code paths (
LR-EDIT-OPTICS-PROFILEbumps), or fold it into the per-format decoder version when the data comes from the raw's maker notes. - Keep a global
RENDER_CACHE_EPOCHfor genuinely global changes (cache file format, key layout, output colour management). It should rarely move.
The key becomes hash(content, settings_hash, size, epoch, pipeline_fix, decoder_version(format), camera_profiles::cache_key(), look_version). All of these are compile-time constants or a table lookup, so the key costs no more than today.
Why this also fixes the PR collisions. Two PRs fixing different formats edit different table entries, so the conflict goes away. Two PRs fixing the same format still conflict, and they should, because they need to be reviewed together.
Make the tables hard to forget. A unit test can pin each table entry next to a golden render hash of a tiny procedural sample for that decoder (where one exists), so a decoder change that alters output without a version bump fails CI. This also catches the opposite mistake: a change that alters output but bumps nothing.
Costs and open questions
- Some fixes touch shared code (demosaic, black levels, the DNG path used by several makes). The author has to decide which formats are affected. Bumping more entries than needed is always safe, and is never worse than today.
- An existing cache becomes invalid once when the key layout changes. That's one more full re-render, the same cost as any bump today.
- Where should the tables live so
cargo xtask layersstays happy? Probably in the decoder crates (L1), read byengine::media. - Is the per-model granularity worth it, given that camera-coverage fixes are usually per model? Per-format first, per-model only if the churn stays high.
Not covered
RENDER_CACHE_VERSION also gates the loupe's "view" render key (media.rs:1222). The same per-component key would apply there unchanged.
Activity
radialmonster commentedon Oct 11, 2026
+1. We've been working on the same split. Here's how we'd build it on current main, in small steps that each stand alone.
1. One fingerprint function, no key change. The persistent key is built inline in three places in
media.rs:build_job(:1100),variant_key(:1142) andview_key(:1230), with a fourth copy in the pinned test (:1524). They all hash the content key, the settings hash, a size or kind tag,RENDER_CACHE_VERSIONandcamera_profiles::cache_key(), andbuild_jobalso adds the denoise salt. A first PR would move them into a singlerender_fingerprintwith extra components that are all 0. A component at 0 adds nothing, so every key stays byte-identical: nothing re-renders, and there's no catalog or version bump. A test checks that the three sites agree and that the result equals today's formula.2. A revision per reader.
RawFormatnow has 17 variants and no per-format revision. Each reader gets a constant starting at 0, and the fingerprint adds the photo's reader revision. A decoder fix then bumps one line and re-renders only that format. Shared code (demosaic, TIFF/LJPEG, the embedded-preview path) stays under the globalRENDER_CACHE_VERSION.3. Record the reader on the photo. Key by the reader the file actually parses as, not by its extension, so RW2/RWL/Panasonic
.RAWshare one revision and a DNG named.rawfollows DNG. Import already probes the file. Reload (SetContent) records the reader again, and undo restores it. Photos without a recorded reader use the combined revision of all readers, which is how it works today, so their cache is never stale. The field needs the next journal version. That's v8 if #800 lands first, so this step would rebase onto it. The field is only a cache hint, so an older build that drops it falls back to the combined key.4. A look revision only where a look is fitted.
fitted_look()andfile_local_lookcover the formats developed from a look fitted to their own JPEG. ALOOK_VERSIONchange should enter the key only for those photos. Today a look-fit change needs a globalRENDER_CACHE_VERSIONbump, which re-renders every photo in every library, JPEGs and DNGs included.5. Lens and as-shot white balance inputs, later. These change the render without changing the settings hash, so they belong in the fingerprint once steps 1–4 are in.
Process versions already work. They reach the key through the settings hash (V1 is left out of it, so V1 keys are unchanged), so changes gated behind a process version need nothing from this. One gap: the in-memory
lin_key/pre_nr_keyleave the process out. That only matters if a process-gated change lands before the linear stage.Questions
On granularity: per format first, as you suggest. Two PRs on the same reader can still collide, but on that reader's line instead of one global line.