Repository navigation
M5.6: Dehaze while zoomed no longer resamples the whole original on every pan and slider step - #1419
Merged
echelon merged 1 commit intoOct 14, 2026
Conversation
…d slider step resampled the whole original) A windowed render dehazes with the whole frame's airlight, estimated on a 384 px proxy of the frame (`local::frame_airlight`). Every window asked for that proxy again, so every pan of a 1:1 view and every slider step while zoomed sampled the whole original down to it on the CPU: ~200 ms of CPU on a 64 MP raw. The proxy (taken before white balance) is now kept for the last 4 (source fingerprint, frame, size); white balance, the dark channel and the percentile still run on it every time. Same pixels: the GPU window of `render_bench` is byte-identical. `optics::fingerprint` indexed the first pixel of an empty image; it now hashes only the dimensions then. render_bench ONLY=window GPU_ONLY=1 on a 64 MP Sony ILCE-7RM6 raw (RTX 4070 Ti SUPER, 4-CPU quota), CPU time: pan 208-212 -> 9-11 ms, exposure change 200-204 -> 4 ms, NR change 211-217 -> 13 ms. Co-Authored-By: Claude <noreply@anthropic.com>
dev-null-undefined
force-pushed
the
claude/dehaze-airlight-cache
branch
from
October 13, 2026 12:29
3b76046 to
e7cd00e
Compare
Member
|
Thank you @dev-null-undefined! This landed on main in integration batch 35 (#1682). If you haven't already, please join our Discord: https://discord.gg/artcraft. We'd love to have you there. |
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.
The problem
With Dehaze on, a zoomed view (a window render, #323) dehazes with the airlight of the whole frame, not that of the pixels in the window.
local::frame_airlightestimates it on a 384 px proxy of the frame. Every window job sampled the whole original down to that proxy again: every pan at 1:1 and every slider step while zoomed.On a 64 MP raw that is ~200 ms of CPU per window, several times what the GPU render of the window itself costs. The CPU pipeline plans windows through the same function, so it pays the same.
The numbers below come from a Sony ILCE-7RM6 64 MP raw on an RTX 4070 Ti SUPER (Ryzen 7 9800X3D) under a 4-CPU cgroup quota.
Changes (one commit; same pixels)
frame_proxykeeps the sampled proxy for the last 4 (source fingerprint, frame, proxy size), usingoptics::fingerprintlike the lateral CA and Upright caches.Framenow derivesPartialEqfor the key.optics::fingerprintindexed the first pixel of an empty image. It now hashes only the dimensions then. The change is byte for byte the one in [On hold, follow-up to #1283] Dehaze: per-channel airlight and a soft veil for negative values (#1237) #1286, so the two merge without a conflict there.Result
main→ this branch,render_bench ONLY=window GPU_ONLY=1 N=7(a 3072 × 2304 window of the 9984 × 6656 frame,typical()settings with Dehaze 10), best of 7, two runs each:Wall clock on
mainvaries with the load on the shared machine (load average ~16). CPU time is stable. The first window of a photo still samples the proxy once. Its row inrender_benchisn't comparable, because the best of 7 hits the cache from the second run on.Verification
render_benchwrites withDUMP=is byte-identical onmainand on this branch.local::tests::the_kept_airlight_proxy_matches_a_fresh_one_and_misses_on_another_source_or_frame: the second request is served from the cache; the airlight is bit-identical to a fresh estimate; another source of the same size and the same source with another crop each get their own.optics::tests::an_empty_image_has_a_fingerprint: panicked onmain("index out of bounds: the len is 0 but the index is 0").cargo xtask ci: fmt, clippy (workspace, all targets) and heif pass; parity, layers, assets and wasm pass.cargo test --workspace --no-fail-fast: everything passes except catalog'stests_lock::dropping_the_lock_frees_the_library_while_another_thread_spawns_processes. That test spawns/bin/true, which doesn't exist on this NixOS machine. It fails the same way onmain, and this PR doesn't touch the catalog crate.RUSTFLAGS="-A clippy::chunks_exact_to_as_chunks". Clippy on rustc 1.98 flags that lint incrates/pipeline/src/spots.rs:250onmain, which this PR doesn't touch.Related
frame.sampleandwhite_balanceinframe_airlight, so the cached proxy stays valid there. The two branches merge without conflicts (git merge-tree).frame.sampleof the whole original. Its cache key includes the white balance, so the final render after a WB drag samples the original again. On a miss it could takeframe_proxy(taken before white balance) instead. With both merged, onlydocs/whats-new.mdconflicts.render_benchwindow scenario used here is in the perf harnesses PR M5.7: perf harnesses for slider latency, zoom windows and photo loading (examples only) #1421. Its rows were renamed there ("window pan …" instead of "window 1:1 pan …") socargo xtask benchcan parse them.