Skip to content

perf: increase diff and startup speed#4

Merged
pmqueiroz merged 4 commits into
mainfrom
perf/speed-improvements
Apr 26, 2026
Merged

perf: increase diff and startup speed#4
pmqueiroz merged 4 commits into
mainfrom
perf/speed-improvements

Conversation

@pmqueiroz
Copy link
Copy Markdown
Owner

Summary

  • Replace fixed 100ms server sleep with HTTP readiness probe — starts as soon as the server is up instead of always burning 100ms
  • Use image::load_from_memory in diff phase — PNG bytes already read for byte-equality check are reused for decoding, eliminating 2 disk reads per non-identical image pair
  • Two-pass pixel comparison — pass 1 counts differing pixels with no allocation; pass 2 builds the RGBA diff image only for stories that fail the threshold; passing stories (the majority) skip ~5MB buffer allocation entirely
  • Fix --update flag — previously had no effect on the diff phase; now copies snapshots to baselines in parallel and skips diff entirely

Commits

  • perf: replace fixed server sleep with readiness probe
  • fix: handle --update flag in diff step
  • perf: eliminate double disk reads and skip diff image alloc on pass

Test plan

  • Run against a large Storybook, verify process completes without hanging
  • Run with --update, verify baselines are updated and no diff runs
  • Introduce a visual change, verify diff image is still generated correctly
  • Check startup logs — server should be ready in <20ms on most machines

🤖 Generated with Claude Code

pmqueiroz and others added 4 commits April 25, 2026 21:09
Polls localhost:1337 every 20ms instead of always waiting 100ms.
Fast machines proceed as soon as the server is up.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Previously --update had no effect on the diff phase — it still ran full
comparisons. Now copies all snapshots to baselines in parallel and
returns early, skipping the diff entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two changes to the diff loop:
- Use image::load_from_memory instead of image::open so PNG bytes
  already read for byte-comparison are reused, halving disk reads for
  non-identical pairs.
- Two-pass pixel comparison: pass 1 counts differing pixels with no
  allocation; pass 2 builds the RGBA diff image only for stories that
  fail the threshold. Passing stories (the majority) skip ~5MB of
  buffer allocation and pixel work entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pmqueiroz pmqueiroz merged commit b297ac6 into main Apr 26, 2026
6 checks passed
@pmqueiroz pmqueiroz deleted the perf/speed-improvements branch April 26, 2026 00:16
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