Skip to content

LPC845 bloat: fl::CRGB::computeAdjustment is 9.5 KB (12.5% of .text) on LowMemory + RX_SCT_WS2812 #3075

Closed

Description

@zackees

Symptom

On the LPC845-BRK Low-memory bring-up (examples/AutoResearch/AutoResearch.ino with FASTLED_AUTORESEARCH_LOW_MEMORY=1 and FASTLED_LPC_RX_SCT_WS2812=1), a single function dominates .text:

9,516 bytes  fl::CRGB::computeAdjustment(unsigned char, fl::CRGB const&, fl::CRGB const&)

That is 12.5% of total .text (76,272 bytes) for one function — and that one function alone is 86% of the 11,040-byte flash overage that keeps the WS2812 SCT-RX RPC binding from fitting in 64 KB.

Why this is surprising

computeAdjustment is the per-pixel color-correction / brightness path on the TX side of WS2812 emission. The Low-memory AutoResearch surface is RX-only (pinToggleRx, ws2812SctTest measure incoming edges; they do not drive an LED strip). There should be no reachable call to computeAdjustment at all from this sketch.

Likely root cause: kept alive by a vtable / function-pointer indirection inside CLEDController::showLeds() that the linker cannot statically prove dead. <FastLED.h> is pulled in to construct timing traits for the WS2812 byte-match decoder; that drags in the controller hierarchy; that drags in computeAdjustment through the v-table.

Repro

# In platformio.ini [env:lpc845brk] uncomment:
#   -DFASTLED_LPC_RX_SCT_WS2812=1
# Temporarily bump FLASH from 64K to 128K in the LPC845 LD script
# (fbuild#594 — there is no proper "emit ELF on overflow" mode today)
PLATFORMIO_SRC_DIR=examples/AutoResearch fbuild build -e lpc845brk
# Parse .fbuild/build/lpc845brk/release/firmware.map -- the 0x.... <demangled>
# lines under `.text 0x00000300 0x12868` show address-derived sizes.

What we want

  1. Confirm whether computeAdjustment is genuinely reachable from the LowMemory + RX-only build (most likely: only through a v-table).
  2. If unreachable in practice, either gate it behind a feature flag, or restructure so the linker can DCE it.
  3. If reachable but overweight, slim the function (currently doing 8-bit by 8-bit dithered scaling for three channels with a fair amount of inline expansion).

Acceptance

  • .text size of fl::CRGB::computeAdjustment drops below 2 KB on LPC845-BRK low-memory build (or is fully DCE-eliminated when no CLEDController is constructed)
  • LPC845 LowMemory + -DFASTLED_LPC_RX_SCT_WS2812=1 link succeeds without the 11 KB FLASH overage attributable to this function

Related

  • fbuild#594 — tooling gap that made measuring this require LD-script patching
  • Meta: (will link)

Activity

  1. zackees commented on Jun 15, 2026

    @zackees
    MemberAuthor

    Tracked under meta #3079 (LPC845 64 KB flash bloat hunt) alongside three sibling bloat sub-issues and the FastLED/fbuild#594 tooling-gap dependency.

  2. zackees commented on Jun 15, 2026

    @zackees
    MemberAuthor

    Closing as filed in error — retraction.

    The 9.5 KB / 2.9 KB / 1.5 KB / 1.25 KB numbers reported in this issue are wrong. They came from a one-off Python script that parsed firmware.map for symbol addresses, then attributed the byte-delta to the next symbol's address as the size of the symbol. That methodology is invalid: the linker map only lists a sparse subset of symbols; the address gap between two listed symbols often contains many unlisted intermediates. My parser attributed all that intervening code to the visible neighbor.

    Verified by running the real arm-none-eabi-nm --print-size --size-sort on the actual ELF (after forcing the link with a temporary LD-script bump per FastLED/fbuild#594):

    Symbol Claimed Actual nm size
    fl::CRGB::computeAdjustment 9,516 B 54 B (0x36)
    fl::string::trim() const 2,966 B 164 B (0xa4)
    fl::basic_string::operator[](unsigned int) 1,572 B 32 B (0x20) + 22 B const = 54 B
    fl::sstream::operator<<(char) 1,250 B 28 B (0x1c)

    All four targets in this issue are within normal small-function sizes. There is no bug here.

    The correct top contributors for the LPC845 LowMemory + RX_SCT_WS2812 build are tracked under the revised meta #3079. The reproducibility / methodology gap that made this mistake easy to publish is tracked in FastLED/fbuild#594 (no bash bloat path for arm-none-eabi today; manual parsing was the only option).

    Apologies for the noise.

  3. moved this from Triage to Done in FastLED Trackeron Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions