Skip to content

perf(presets): reuse cached text and user preset data - #1222

Merged
bflatastic merged 1 commit into
storytold:mainfrom
arnav-hiwarkar:perf/preset-panel-cache
Oct 16, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
arnav-hiwarkar:perf/preset-panel-cache

Conversation

@arnav-hiwarkar

Copy link
Copy Markdown
Member

Why

Effects & Presets reparses the built-in text catalog and copies every cached custom preset name and path on redraw. Reuse both catalogs to reduce repeated work, especially for large preset folders.

Scope

  • Cache parsed text definitions in OnceLock, shared by listing and application.
  • Return the existing Arc<Vec<PresetFile>>, filter borrowed rows, and copy apply payloads only on double-click.
  • Keep search, ordering, five-second rescans, Refresh List, and undo behavior.

Verification

  • CARGO_PROFILE_RELEASE_LTO=false cargo xtask ci passed: 3,400 tests, Clippy, layers, assets, and WASM checks.
  • Default debug and release workspace builds passed.
  • Regression tests cover all eight text presets, search and double-click application, undo, exact cache expiry, and forced refresh after file changes.
  • The release desktop app passed search, built-in and custom preset application, undo, external definition edits, and deletion/restoration rescans with an isolated config and Unicode folder.
  • Local warm text-listing medians were 19.3 µs before and 0.47 µs after. Two ignored benchmark tests cover text listing and a 1,000-entry custom cache.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed da06216. No blocking findings. The static built-in text definitions are reused through OnceLock without sharing mutable application state. Custom preset rows borrow the existing Arc catalog, and application payloads are constructed only on activation; expiry, forced refresh, search and undo behavior remain intact.
Independent fresh-build validation passed 2 engine preset tests, 4 preset unit tests and 3 UI integration tests, plus formatting, strict engine/UI all-target Clippy and relevant WASM compilation. Source hashes were unchanged. Two benchmark cases were ignored; no new performance numbers are claimed. WASM emitted the existing State.disabled dead-code warning. No full-workspace or native desktop qualification is implied.

@bflatastic
bflatastic merged commit 7dc488b into storytold:main Oct 16, 2026
@bflatastic

Copy link
Copy Markdown
Member

Merged, thank you @arnav-hiwarkar! It landed on main with your other eight PRs as one batch, after a full workspace build: fmt, clippy -D warnings, the whole test suite, layers, assets and wasm.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants