Repository navigation
PERF-PRESETS: libraries with thousands of presets stay responsive - #1056
Merged
Merged
Conversation
…frame A Lightroom collection imported whole (11 113 presets, a 42 MB presets.json) made every interaction take seconds: - Session::persist ran after every command and serialized the whole preset list to compare it with the last write: 609 ms per slider tick (release, the real collection). Session::presets is now a PresetList whose generation changes on mutable access; persist serializes only when it (or the profile lists) changed, and skips the write when the bytes hash the same. develop.set: 609 ms -> 2.3 ms; preset.apply: 598 ms -> 3.1 ms. - The Presets panel deep-cloned every preset into a BTreeMap, built a row, widget id and (with thumbnails) a variant render job for each of them every frame. Grouping is cached per generation and only rows in view are laid out: 5041 -> ~20 rows a frame, 2.3 ms with 5000 presets. - The preset pickers (Import dialog, Settings > Import) build only the rows in view. - add_presets and opening a library compared every preset with every other (quadratic); both use hash indexes now. Opening no longer serializes the list once just to remember it. Tests: develop commands don't re-serialize unchanged presets (and a change is still saved), generation semantics, a 20 000-preset import, and the panel building only visible rows (fails on the old code: 5041 rows). An ignored bench (presets_scale_bench, LIGHTCRAFT_BENCH_PRESETS) times a real presets.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Landed on main in #1438 — thank you, @OneSlips, for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft |
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.
Split out of #1012 at a reviewer's request.
Problem
A Lightroom preset collection imported whole (11,113 presets, a 42 MB
presets.json) made every interaction take seconds:Session::persistran after every command and serialized the whole preset list just to compare it with the last write: 609 ms per slider tick (release build, the real collection).BTreeMapand built a row, widget id and (with thumbnails) a variant render job for each of them, every frame.add_presetsand opening a library compared every preset with every other (quadratic).Fixes
Session::presetsis now aPresetListwhosegeneration()changes on mutable access.persistserializes only when it (or the profile lists) changed, and skips the write when the bytes hash the same. Opening a library no longer serializes the list once just to remember it.PresetList::generation()(grouped()), and only rows in view are laid out (rows_in_view()+allocate_spacefor the rows above/below). Move to Group reads its targets from the cached groups. The panel keeps upstream's current (docking / UI.9) layout.import.rsandpanels/settings.rsuse a sharedpicker_rows()that builds only the rows in view (ScrollArea::show_rows).add_presetsand library open use hash indexes instead of pairwise comparisons.Measured (release, the real 11,113-preset collection)
develop.setpreset.applyTests
crates/engine/src/tests_presets_scale.rs: develop commands don't re-serialize unchanged presets (and a change is still saved), generation semantics, a 20,000-preset import. An ignored bench (presets_scale_bench,LIGHTCRAFT_BENCH_PRESETS=<presets.json>) times a real collection.ui-eguiheadless::tests::presets_panel_with_thousands_of_presets_builds_only_visible_rowsguards the virtualization (fails on the old code: 5,041 rows).docs/whats-new.md: one entry, "Large preset collections".Verification (Windows 11)
cargo fmt --all -- --check,cargo xtask parity,layers,assets,wasm: pass.--features heif, codecs/heif tests, engineheictest): pass.cargo clippy --workspace --all-targets -- -D warnings: the only errors are the two pre-existing upstream lints (chunks_exact_to_as_chunksinpipelinespots.rs, deaddescriptor_copyin cataloglock.rs); clean with-A clippy::chunks_exact_to_as_chunks -A dead_code. Nothing in this PR touches those files.cargo test --workspace --no-fail-fast: the new tests pass (tests_presets_scale::*,headless::tests::presets_panel_with_thousands_of_presets_builds_only_visible_rows). The remaining failures are the known upstream Windows ones, fixed in the separate Windows PR:tests_filesystem_history::*(7),sidecar::tests_repair_*(10),rename::tests::folder_moves_repair_retained_sidecars_before_changing_paths,tests_folders::photos_move_to_another_folder_with_their_sidecars_and_back_on_undo, andeditors::tests::desktop_entries_give_their_program. Four timing-sensitive tests failed under the full parallel run and pass alone (apple_photos::tests::shutdown_follows_an_export_into_its_import,export_task::contact_sheet_tests::contact_sheet_menu_dialog_picker_and_background_export,headless::tests::a_screenful_of_small_faces_is_not_evicted_and_left_blank,headless::tests::a_slow_photos_import_never_blocks_the_window).🤖 Generated with Claude Code