Skip to content

chore(bloat): ratchet baseline 350568 -> 350127 (post-#2908 fl::sort_small) - #2909

Merged
zackees merged 1 commit into
masterfrom
chore/ratchet-baseline-350127
Jun 7, 2026
Merged

zackees merged 1 commit into
masterfrom
chore/ratchet-baseline-350127

Conversation

@zackees

@zackees zackees commented Jun 7, 2026 •

Copy link
Copy Markdown
Member

Measured against `master @ 731e4d5` (PR #2908 just merged):

```
Total flash: 350,127 B (3,627 sized flash symbols).
(was: 350,568 B / 3,631 symbols on master @ 824cb5c)
```

Delta: −441 B / −4 symbols, attributable to the 4 dead-stripped template instantiations from the eliminated quicksort_impl call sites: `fl::detail::quicksort_impl`, `fl::detail::partition`, `fl::detail::heap_sort`, `fl::detail::median_of_three`.

The map-derived attribution to `fl::ClocklessIdf5<...>::ClocklessIdf5()` itself stays at 48,694 B (the rodata-pool blocks anchored under main.cpp.o weren't reachable from the quicksort code, so they don't shift).

Refs #2886, #2907, #2908.

Summary by CodeRabbit

  • Tests
    • Updated ESP32-S3 code size baseline measurement to reflect current binary size.

…small)

Measured against `master @ 731e4d5` (PR #2908 just merged):

    Total flash: 350,127 B  (3,627 sized flash symbols).
    (was: 350,568 B / 3,631 symbols on master @ 824cb5c)

Delta: −441 B / −4 symbols, attributable to the 4 dead-stripped
template instantiations from the eliminated quicksort_impl call sites:

  - fl::detail::quicksort_impl
  - fl::detail::partition
  - fl::detail::heap_sort
  - fl::detail::median_of_three

The map-derived attribution to `fl::ClocklessIdf5<...>::ClocklessIdf5()`
itself stays at 48,694 B — the rodata-pool blocks anchored under
main.cpp.o weren't reachable from the quicksort code, so they don't
shift.

This is the measured fl::sort_small saving. Real but smaller than the
3-9 KB projected in #2907 — the existing quicksort_impl was more
compact than expected.

Refs #2886, #2907, #2908.
@zackees
zackees merged commit 780ab73 into master Jun 7, 2026
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ca79b3dc-e9eb-4ab4-9803-6fa3db3e522a

📥 Commits

Reviewing files that changed from the base of the PR and between 731e4d5 and bdd3754.

📒 Files selected for processing (1)
  • tests/data/esp32s3_bloat_baseline.txt

📝 Walkthrough

Walkthrough

Simple update to the ESP32-S3 bloat test baseline, changing the recorded binary size threshold from 350568 to 350127 bytes.

Changes

ESP32-S3 Bloat Baseline Update

Layer / File(s) Summary
ESP32-S3 bloat baseline
tests/data/esp32s3_bloat_baseline.txt
The measured binary size baseline for ESP32-S3 is updated from 350568 to 350127 bytes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~1 minute

Possibly related issues

  • FastLED/FastLED#2903: Previous adjustment to the same baseline file that set the value to 350568; this PR updates it further to 350127.
  • FastLED/FastLED#2907: Bloat reduction work directly related to the baseline measurement updates reflected in this file.

Possibly related PRs

  • FastLED/FastLED#2861: Optimization changes to RMT memory management that likely impact the ESP32-S3 binary size reflected in this baseline adjustment.

Poem

🐰 A baseline number, trimmed down with care,
From 350568 to 350127 fair,
Bytes saved by careful code refine,
The bloat test now reflects the line! ✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ratchet-baseline-350127

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 7, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 7, 2026
zackees added a commit that referenced this pull request Jun 7, 2026
…rop __ieee754_pow (#2911)

Closes #2910.

Replaces `fl::pow(double, double)` with `fl::s16x16::pow` (integer
fixed-point) in the two FastLED-owned callers that pull `__ieee754_pow`
(libm, 2,723 B in the post-#2908 audit) into release builds.

## What changes

| File | Site | Before | After |
|---|---|---|---|
| `src/fl/math/ease.cpp.hpp` | `Gamma8Impl::Gamma8Impl(float)` | `fl::pow(double, double)` per LUT entry | one `fl::s16x16(gamma)` ctor + per-entry `fl::s16x16::pow` |
| `src/fl/gfx/colorutils.cpp.hpp` | `applyGamma_video(u8, float)` | bare `pow(orig, gamma)` (float args → double) | `fl::s16x16::pow` |

`fl::s16x16::pow` is implemented as `exp2_fp(exp * log2_fp(base))`
where `exp2_fp` and `log2_fp` are pure integer LUT-based
implementations — zero libm dependency. The chain is broken at the
ctor / function entry: the public API still takes `float gamma`, but
that float is converted once to `fl::s16x16` via the constexpr ctor
(one fmul + cast → `__mulsf3` + `__fixsfsi`, both << 100 B).

## Precision sanity-check

- `Gamma8Impl` LUT is u16-valued. `s16x16` has 16 fractional bits
  (~1.5×10⁻⁵ resolution) — well above the LUT's 16-bit output
  resolution.
- `applyGamma_video` is u8 → u8. Same story.
- Result is computed in [0, 1] then scaled to u16 / u8 with
  round-half-up via integer math:
  `((raw_u32 * scale) + 0x8000) >> 16`.

## Why s16x16 is enough

`s16x16` is 16 integer + 16 fractional bits — range ~[-32768, 32767].
- Gamma values are typically in [1.0, 4.0]: fits with massive headroom.
- `(i/255)` is in [0, 1]: stored as raw [0, 65536].
- Intermediate `exp * log2_fp(base)` for `base ∈ (0, 1]` and `exp ∈
  [1, 4]`: `log2(base) ∈ [-∞, 0]`, but `s16x16::log2_fp` clamps
  small inputs. The product stays in s16x16 range.
- `exp2_fp(...)` returns [0, ~1] for the gamma case → fits.

## Out of scope

- `third_party/cq_kernel/fft_precision.h` — third-party FFT macro-driven.
- `third_party/stb/truetype/stb_truetype.cpp.hpp` — third-party font rasterizer.
- `fl::pow` fixed-point template specializations — different overloads, not affected.

## Verification

- `bash lint --cpp` → all C++ linting checks pass.
- `bash test --cpp fl/gfx/gamma_lut` could not be run from the disposable
  PR worktree due to the known meson source-path bug at #2887. The
  same diff applied to the main checkout will run on CI's
  `unit tests linux` job.
- Behavior preserved (modulo ±1 LSB rounding from fixed-point vs
  double): `Gamma8Impl` LUT entries should match the original within
  rounding precision; `applyGamma_video` preserves the
  "never-down-to-zero" invariant via explicit `result == 0 → 1`.

## Expected savings

- Eliminated: `__ieee754_pow` (2,723 B).
- Eliminated: any related double-math symbols only reachable via this path.
- Added: `__mulsf3`, `__fixsfsi` (<< 100 B each — likely already
  linked by other float math sites).
- Net: projected ~2-2.5 KB on the ESP32-S3 NEOPIXEL Blink build.

The Stage 6 regression gate (`tests/test_esp32s3_bloat_regression.py`,
baseline = `350127`) validates the measurement on this PR's CI run. A
follow-up commit lowers the baseline file accordingly.

Refs #2886, #2910, #2908, #2909.
@zackees
zackees deleted the chore/ratchet-baseline-350127 branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant