Skip to content

Mitigate slow Auto-paint searches on high-color photos - #154

Merged
vycdev merged 3 commits into
developfrom
t3/auto-paint-search-performance
Nov 15, 2026
Merged

vycdev merged 3 commits into
developfrom
t3/auto-paint-search-performance

Conversation

@vycdev

@vycdev vycdev commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Small unquantized photos can start minutes of Enhanced Auto-paint work because search cost scales with distinct target colors. This adds guidance before expensive searches and an explicit way to stop them.

Refs #103.

Changes

  • Pause Enhanced searches at 1,024 or more weighted target colors. Explain 2D quantization to 16-32 colors, repeats off, and Fast / Compact; provide a shortcut for the cheaper settings and an explicit Run Auto-paint action.
  • Add Cancel Auto-paint through the existing worker-termination path. Cancelled searches stay stopped until restarted or inputs change, including cancellation during the debounce and rejection of late worker messages. Run/Cancel choices expire when inputs change, so returning to earlier settings cannot restore an obsolete cancellation or search approval.
  • Reuse the exact winning CIEDE2000 error and precompute unchanged chroma, uncertainty, and segment values. Target colors, weights, arithmetic, tie breaking, seeds, and HD/TD storage and rounding are preserved.
  • Localize controls and both guides in all 12 languages, update the unreleased changelog, and add threshold, cancellation, and result-equivalence regressions.
  • Allow a private smoke-test port and disable WebSocket listeners in the in-process test/benchmark loader.

Measurements and equivalence

The revised 1,024-target advisory comes from a fixed-seed Balanced / Detailed sweep with 12 repeats: 512 targets completed in 12.134 seconds, 1,024 in 19.574 seconds, and 2,048 in 36.557 seconds. This replaces the initial cutoff based only on Fast / Compact. The warning is a color-count advisory, not a runtime limit or ETA; smaller palettes can still be expensive with deeper search or more filaments.

At 142,066 synthetic targets, median scoring time per 24 candidates changed from 17.975 to 16.878 seconds (6.1% less time). Smaller palettes had mixed timing results, and large repeated searches remain expensive. This workload is not the unavailable original photo. Recorded scoring fingerprints match at every benchmark count. Runtime-portable regression tests compare complete final stacks and exact scores with frozen pre-change scoring functions, using seed 12345 for all 12 existing enhanced image/profile cases and four synthetic searches.

Benchmark method, full timings, threshold rationale, and raw samples.

Validation

  • npm run lint
  • npx tsc -b
  • npm run check:i18n
  • npm test: all 1,133 tests passed on the current revision
  • All eight e2e suites passed for the initial implementation; the current lifecycle/threshold follow-up passed test:e2e:docs and three repetitions of the guidance/cancel specs
  • Exact reference comparisons passed on Node 22.23.4 and Node 24.19.0
  • Both Run and Cancel settings-round-trip assertions failed before the fix; all six browser executions passed afterward. Debounce timing uses a controlled browser clock

Browser verification used private port 5287, with its listener confirmed to belong to this worktree.

@vycdev
vycdev merged commit 079083c into develop Nov 15, 2026
11 checks passed
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.

1 participant