Skip to content

Maximize frame throughput across all effects - #3

Merged
dhh merged 11 commits into
masterfrom
perf/max-fps-autoresearch
Aug 10, 2026
Merged

Maximize frame throughput across all effects#3
dhh merged 11 commits into
masterfrom
perf/max-fps-autoresearch

Conversation

@dhh

@dhh dhh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

This PR completes the FPS autoresearch pass with eleven separately measured optimization commits.

Combined result

Pinned-core, alternating-order benchmark against master (ca54938), using 11 samples per effect on the established 100x30 corpus:

  • Aggregate FPS across all 35 non-clock effects: 19,873.98 -> 23,305.04 (+17.26%)
  • Geometric-mean per-effect speedup: 1.185x
  • Median per-effect speedup: 1.178x
  • Total median runtime: 1299.337 -> 1108.044 ms (-14.72%)
  • Faster effects: 35 of 35
  • Complete frame streams: byte-identical for 35 of 35 effects

A dense 200x50 comparison across Beams, Waves, Colorshift, Highlight, Expand, and Middleout improved aggregate FPS by 32.49%. All six complete streams remained byte-identical.

Accepted wins

  • Render directly from the reusable cell buffer, removing a full-frame copy.
  • Evaluate quadratic Bezier paths without per-frame heap allocation.
  • Parse the xterm palette once and memoize RGB conversions. Sampled xterm workloads improved 3.17x to 6.61x.
  • Initialize Beams character scenes once. Standard FPS improved 2.151x in the final combined benchmark; dense FPS improved 1.985x.
  • Skip unchanged Matrix rain visuals while preserving RNG draws. Isolated 200x50 runs improved 1.86x to 5.68x depending on color mode.
  • Borrow SequenceEaser deltas instead of cloning cumulative character sets.
  • Reuse the Overflow queue and borrow gradient state.
  • Abort on panic in release builds. The final release binary is about 31% smaller than the original master binary.
  • Store RGB colors inline with cached parsed channels. This alone delivered +11.6% geometric-mean FPS across 35 effects.
  • Use an adaptive sorted-vector/bitmap active-character set. Dense effects improved roughly 6% to 14%.
  • Bucket character groups in one pass. The grouping primitive improved 7.03x overall, with Matrix first-frame build improving 5.2%.

Validation

  • cargo test --release: 23 tests passed across unit and integration suites
  • Effect parity: 354 passed, 0 failed
  • Terminal byte-stream parity: 41 passed, 0 failed
  • CLI corpus: 19 passed, 0 failed
  • GitHub CI: Linux tests/parity, macOS tests, and static musl binary all passed
  • git diff --check: clean

Compatibility note

The compact RGB representation changes the public Rust field types from heap-backed strings to RgbString and prevents external Color struct literals. The project is binary-focused; command behavior and rendered output remain byte-identical.

@dhh

dhh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Two more measured wins landed:

  • aba5ead: stack-only quadratic Bezier motion. Paired isolated results: Fireworks +5.74%, Laser Etch +1.95%. Quadratic-effect parity: 40/40.
  • 9238455: shared xterm conversion cache plus one-time palette parsing. At 200x50: Waves 4.03x, Sweep 3.17x, Overflow 6.61x faster. Xterm parity: 70/70; reference comparison: 4,913 RGB samples.

@dhh

dhh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Two effect-specific wins landed:

  • 43c22fb: initialize Beams scenes once instead of once per row and again per column. Default +72.5% FPS; dense 200x50 +71.7%; parity 8/8.
  • 394109d: skip rebuilding unchanged Matrix rain visuals while preserving RNG draws. 200x50/600 frames: RGB 2.81x, no-color 1.86x, xterm 5.68x; parity 12/12 and full-stream hashes identical.

@dhh

dhh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

de78539 removes SequenceEaser deep clones by returning borrowed added/removed deltas. Dense 200x50 marginal frame time: Wipe -2.2%, Highlight -14.9%, Sweep -7.6%. Focused parity 30/30; full tests pass.

@dhh

dhh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

6b98670 removes Overflow gradient deep-copying and switches the pending-row queue from O(n) front removals to VecDeque. End-to-end gains are +0.6% to +1.4% across RGB/xterm/no-color and 64x20/200x50; parity 12/12 and full tests pass.

@dhh

dhh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

8efa1f3 enables panic=abort for release builds: paired all-35 throughput +1.38%, binary size 3.28 MB -> 2.55 MB (-22%). Release tests, 354 effect parity cases, and 41 TTY parity cases pass.

@dhh

dhh commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

539723a stores RGB spellings/channels inline so Color is Copy: Color shrinks 56 -> 22 bytes and ColorPair 112 -> 44 bytes. Across 35 non-clock effects: +11.6% geometric-mean FPS, +12.0% median; dense 200x50 Beams +18.6%, Waves +18.2%, Smoke +16.8%. Candidate/base streams were identical for 354/354 effects and 41/41 TTY cases; release tests and CLI pass. Note: this intentionally changes the public rgb_color field from String to RgbString.

@dhh dhh changed the title Autoresearch: maximize frame throughput Maximize frame throughput across all effects Aug 10, 2026
@dhh
dhh marked this pull request as ready for review August 10, 2026 13:07
@dhh
dhh merged commit 8680559 into master Aug 10, 2026
3 checks passed
@dhh
dhh deleted the perf/max-fps-autoresearch branch August 10, 2026 13:07
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