Skip to content

perf(stl): force-inline fl:: libc wrapper templates (-76 B ESP32-S3) - #4833

Merged
zackees merged 1 commit into
masterfrom
fix/libc-wrapper-force-inline
Oct 14, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/libc-wrapper-force-inline

Conversation

@zackees

@zackees zackees commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #4830 (#4827).

Cause of #4830's ESP32-S3 growth: making fl::memcpy/memset/memmove templates led GCC to emit out-of-line $isra clones of the forwarders (+42 +42 +14 B, from CI bloat reports of run 38476137054 vs 38445221273). #4830 re-based the budget saying master was already over; that was wrong (based on a local build; CI measured 341027 on a branch off master).

Fix: FASTLED_FORCE_INLINE on all template <typename FlLibcTag = void> wrappers in fl/stl/cstring.h, malloc.h, cstdlib.h.

Evidence: local bash bloat esp32s3 --build image 341039 (was 341115), clones absent from report. Budget pinned to the expected CI value 341055 (local + CI's usual +16 B); will re-pin to the measured CI value if different. Baseline note corrected.

bash lint clean, bash test --cpp 321/321 unit, 96/96 examples.

Summary by CodeRabbit

  • Improvements

    • Reduced the ESP32-S3 Blink build’s flash usage by 76 bytes, with RAM usage unchanged.
    • Updated C library and string/memory wrappers to encourage more efficient inlining.
  • Documentation

    • Corrected the ESP32-S3 size baseline and revised the related build comparison notes.

…3) (#4827)

PR #4830 made fl::memcpy and friends 'template <typename = void>' so libc
wins ADL ties. GCC on ESP32-S3 emitted out-of-line clones of the
memcpy/memset/memmove wrappers (+98 B). Force-inline them. Also correct
the bloat-baseline note from #4830, which wrongly said master was
already over budget.
@zackees zackees added the ci-test:bloat Select FastLED board CI cells label Oct 14, 2026
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Oct 14, 2026
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: FastLED/FastLED/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3aac96c9-5881-4978-afb3-5be63d57c37e
📥 Commits

Reviewing files that changed from the base of the PR and between 401b03e and cf0a8a2.

📒 Files selected for processing: 5
  • src/fl/stl/cstdlib.h
  • src/fl/stl/cstring.h
  • src/fl/stl/malloc.h
  • tests/data/esp32s3_bloat_baseline.txt
  • tests/data/esp32s3_bloat_budget.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The STL wrappers now use FASTLED_FORCE_INLINE, and malloc is a function template with a defaulted FlLibcTag parameter. The ESP32-S3 baseline and budget data now record 341055, with revised benchmark notes.

Changes: STL wrapper updates

Layer / File(s) Summary
Wrapper declarations and annotations
src/fl/stl/cstdlib.h, src/fl/stl/cstring.h, src/fl/stl/malloc.h
The wrappers use FASTLED_FORCE_INLINE and include compiler_control.h. malloc gains a defaulted FlLibcTag template parameter. The wrappers’ delegated implementations remain unchanged.
ESP32-S3 baseline references
tests/data/esp32s3_bloat_baseline.txt, tests/data/esp32s3_bloat_budget.json
The pinned baseline and image_flash budget change from 341131 to 341055. The files revise the benchmark comparison notes.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to cf0a8

No demonstrated issue blocks merging after normal checks; confirm the ESP32-S3 budget against CI when its measurement is available.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 3 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: force-inlining the fl:: libc wrapper templates to reduce ESP32-S3 binary size by 76 bytes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 40 functions across 3 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@zackees
zackees merged commit d4a2d3a into master Oct 14, 2026
233 of 236 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Oct 14, 2026
zackees added a commit that referenced this pull request Oct 14, 2026
… (#4835)

Any function at namespace scope inside fl (or a sub-namespace) whose name
is a libc name (full C11 string.h/stdlib.h, strings.h, POSIX/newlib/glibc
extras) must be a 'template <typename FlLibcTag = void>' +
FASTLED_FORCE_INLINE wrapper, so unqualified libc calls on fl types stay
unambiguous (#4827) and the forwarders stay inline (#4833).
fl::libc_impl is exempt; no path allowlist.

Fixes found by the rule:
- fl::isr::memcpy -> fl::isr::memcopy (internal; matches fl::memcopy)
- fl::exit becomes the template wrapper form

tests/fl/stl/adl_barrier.cpp now resolves every wrapper unqualified, on
CRGB* without a using-directive and under using namespace fl.
@zackees
zackees deleted the fix/libc-wrapper-force-inline branch October 14, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-test:bloat Select FastLED board CI cells

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant