Repository navigation
Description
Symptom
check_teensy41_size workflow has been red on master for many consecutive runs (continuously since at least 2026-05-30 15:25). Latest: run 26703433838 at 7d834f2.
The Blink example check passes:
teensy41 size 57340 is within the limit of 120000
But the Apa102 example check fails ~1.69x over budget:
teensy41 size 148476 is greater than max size 88000
##[error]Compiled size exceeds maximum allowed size
Root cause (preliminary)
A symbol dump of the teensy41 Apa102 firmware ELF shows the binary is dragging in code that has nothing to do with APA102 SPI LED output. Sampled symbols (full nm dump in the run log):
Async logger / task infrastructure:
fl::detail::AsyncLoggerServiceTask(ctor/dtor/InlinedLambda destroy)fl::AsyncLogQueue<128, 4096>(full ringbuffer impl — push/pop/load/commit/atomicIncDropped/...)fl::detail::async_log_flush_timer_isr
HTTP / task::Error machinery:
fl::net::http::StreamHandle::catch_(fl::function<void(const fl::task::Error&)>)fl::function<void(const fl::task::Error&)>::NonConstMemberCallablevtablefl::function<void(const fl::task::Error&)>::ConstMemberCallablevtablefl::variant<shared_ptr<...>, FreeFunctionCallable, InlinedLambda, NonConstMember, ConstMember>move/destroy tables
None of this should be present in a sketch that does:
FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS);The Blink example shows the same teensy41 chipset cleanly fits in 57.3 KB; the additional ~91 KB in Apa102 is being pulled in by something between SPI chipset selection and what gets linked.
Likely culprits
The async system was unified under fl/stl/async/ in early March (per recent CLAUDE.md memory). That move + the HTTP/Asio addition is a strong candidate for being eagerly included via a header chain ending at FastLED.h or one of the chipset headers. The split between "user includes FastLED.h" → "ends up with HTTP" is the regression vector.
Not raising the budget
Per user directive on the equivalent esp32dev_binary_size situation (#2608): do not raise budgets to mask bloat regressions. The right fix is to find the include chain that pulls async/HTTP into a SPI-only sketch and break it (e.g., move impl into .cpp.hpp behind a feature-flag include guard, or push the logger init to a separate header users opt into).
Investigation entry points
- Reproduce locally:
bash compile teensy41 --examples Apa102thenarm-none-eabi-nm -S --size-sort .build/pio/teensy41/.pio/build/teensy41/firmware.elf | head -50to see the largest contributors. - Trace which header pulls in
fl::detail::AsyncLoggerServiceTask. Likely entry point is whateverFastLED.hultimately includes for logging — that header probably unconditionally instantiates the async logger task instead of stubbing on bare-metal Arduino targets. - The
fl::function<...task::Error...>infrastructure is a strong hint thattask.his being pulled into FastLED.h's transitive closure.
Filed but no PR
Filing this as an issue rather than a PR because the right fix is a multi-file include refactor and warrants explicit owner buy-in (could legitimately break public API expectations on what #include <FastLED.h> brings in). Loop iteration halts per "halt if can't fix" — but the bloat signature is now documented for whoever picks it up.
Related
- esp32dev_binary_size: stale 330 KB budget vs 635 KB reality on platformio backend #2608 (esp32dev_binary_size — same pattern of size budget exceeded; user-deferred)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon May 31, 2026
Same root cause hits
teensy30workflow too.Run 26703433897 at
7d834f2. Every example fails with the same signature — RAM region overflow (teensy30 = Kinetis MK20DX128, 16 KB RAM total):Overflowing by ~22 KB more than the chip's 16 KB RAM is comically over budget — the async logger's
AsyncLogQueue<128, 4096>(4 KB arena + 128*32 B descriptors = ~8 KB) alone plus thefl::function<void(const fl::task::Error&)>callable storage explains the bulk of it.This is the same regression as the teensy41 Apa102 case in the issue body — just hits harder because teensy30's RAM is 16 MB smaller than teensy41's.
Until the include-graph decoupling lands,
teensy30andcheck_teensy41_sizewill stay red. Filing only as a comment (not a new issue) since the root cause is identical.zackees commentedon Jun 5, 2026
Investigation update — async logger / HTTP not the cause; real culprit is
FASTLED_SPI_USES_CHANNEL_APIrouting APA102 throughfl::channelsTook another pass at the failing
check_teensy41_sizebuild (run 27006203252, sha787de450). Working strictly from the linker map (firmware.map) — both the Discarded input sections dump and the kept sections dump — the original symbol hypothesis turns out to be wrong, and the real bloat lives somewhere else entirely.What's actually in the final Apa102 ELF
-ffunction-sections -fdata-sections -Wl,--gc-sectionsare all active for the teensy toolchain — every.cpp.hppfunction lands in its own.text._Z…section, and--gc-sectionsstrips anything unreferenced. The async logger and HTTP symbols listed in the issue body show up in the Discarded input sections block of the map (fl.log+.cpp.oandfl.stl+.cpp.o), so they are present inlibFastLED.abut not present in the linked firmware.Per-archive-member byte totals in the kept region of the Apa102 map (vs. Blink for the same revision):
libFastLED.a(fl.channels+.cpp.o)libFastLED.a(platforms+.cpp.o)libFastLED.a(fl.stl+.cpp.o)libFastLED.a(fl.system+.cpp.o)libFastLED.a(fl.gfx+.cpp.o)libFastLED.a(fl.log+.cpp.o)libFastLED.a(fl.task+.cpp.o)fl.log+.cpp.ocontributes exactly the same 234 bytes (fl::fastled_file_offset) in both builds —AsyncLoggerServiceTask,AsyncLogQueue<…>,async_log_service,async_log_flush_timer_isr, and thefl::function<void(const fl::task::Error&)>vtables are all in Discarded input sections for both Blink and Apa102. Same forfl::net::http::ChunkedReader,HttpRequestParser,HttpResponseParser— all discarded.So the original investigation entry point — "trace
AsyncLoggerServiceTask" — is a dead end. Those symbols visible vianmonlibFastLED.aare pre-link archive contents, not linked code.The actual include chain
The link map's "Archive member included to satisfy reference by file (symbol)" block for the Apa102 link gives the real chain (one critical row):
main.cpp.o(the user's Apa102 sketch) directly instantiatesfl::ChannelConfig::ChannelConfig(SpiChipsetConfig const&, …). That's the entry point. It is reached from this header trail:The
addLeds<APA102, ...>template, on Teensy 4.x, does not call intoAPA102Controller/legacySPIOutput— it constructs afl::ChannelConfigand hands it tofl::ChannelManager::add(...). That single call drags the entirefl/channelsmachinery into the link (manager, dispatcher, the variant-of-PixelControllers, SpiChannelEngineAdapter, PixelIterator, function_list, quicksort, all SPI HW backends, etc.).Introduced by commit
badef0c5d("update spi with channels api where applicable", 2026-04-02) and gated on Teensy 4.x atsrc/FastLED.h:96.What's chewing the 55 KB of
fl.channels+.cpp.oTop per-symbol byte counts in the kept region (filtered to
fl.channels):platforms+.cpp.oadds ~25 KB more for the teensy spi_hw_2/4/manager backends and the channel-driver init list.Proposed fix (the surgical break)
The right fix is the same kind of opt-in escape hatch that already exists for WASM (
FASTLED_FAKE_SPI_FORWARDS_TO_FAKE_CLOCKLESS,FastLED.h:71-77) — but for the channel-API SPI path on Teensy 4.x:Keep the legacy SPI controller path (
FASTLED_SPI_USES_CHANNEL_API == 0) available on Teensy 4.x and make the channel-API path opt-in via a user-defined macro:i.e. drop
FL_IS_TEENSY_4Xfrom the default-on list. ESP32 keeps the new API; Teensy 4.x reverts to the legacy clocked SPI controller (which was working until April 2). User code can re-opt-in with-DFASTLED_SPI_USES_CHANNEL_API=1.Stretch goal — make the channel-API SPI path lazier even when enabled: the
Channel::showPixelstemplate is instantiated for onePixelController<RGB,1,…>per addLeds call, but the variant infl::channelscarries everyEOrder× every chipset, which is whyquicksort_impl,function_list::invoke, thevariant::visit_fnfamily, the three HD encoders, the WS2812 encoder, and the UCS7604 writer all link unconditionally even from a singleAPA102+RGBinstantiation. That's the structural cost — splittingfl/channels/_build.cpp.hppso SPI-only sketches don't link the clockless/UCS7604/HD-encoder fallbacks is a larger refactor (the right Phase-2 follow-up).API impact
Path (1) is API-preserving for the user:
FastLED.addLeds<APA102, …>(…)keeps the same signature. Internally the constructed controller type changes fromfl::Channel/SpiChannelEngineAdapterback toAPA102Controller/SPIOutput<…>. The runtime-discoverablefl::ChannelManager::forEachetc. won't see APA102 instances on Teensy 4.x — that's a behavior shift for anyone relying on the new channel registry on Teensy. Anyone who wants that on Teensy can#define FASTLED_SPI_USES_CHANNEL_API 1before#include <FastLED.h>.Estimated size benefit
Pulling
fl.channels+.cpp.oout of the Apa102 link drops ~55 KB; theplatforms+.cpp.odelta of ~25 KB is part dependent (SpiHw2/4 backends + channel-driver init list). Most of the latter is still needed for clockless drivers but the SPI-specific portion (~10–15 KB) should also fall away. Realistic landing zone: ~60–70 KB removed, putting Apa102 around 80–90 KB — within (or right at) the 88 KB budget.Why I'm filing as comment, not PR
The default-flip on
FASTLED_SPI_USES_CHANNEL_APIis a public-surface decision (it changes which controller objectaddLeds<APA102,…>returns on Teensy 4.x, and which registry the LED strip is discoverable through). Wants @zackees ack before shipping. Happy to draft the one-line PR (dropFL_IS_TEENSY_4Xfrom the default-on conditional + anews/entry + add-DFASTLED_SPI_USES_CHANNEL_API=1documentation) the moment that's blessed.The async-logger / HTTP angle in the issue body should be edited / struck — those symbols genuinely aren't in the linked firmware.
zackees commentedon Jul 16, 2026
Local fbuild bloat investigation (2026-07-16)
The open APA102 regression is confirmed, but the original async logger/HTTP hypothesis is not: those symbols are present in discarded archive sections, not retained in the final ELF.
Blink baseline with the current Teensy Audio LDF shim
bash compile teensy41 --examples Blinkfollowed byfbuild symbolsshowed:flash=100352 B,ram=72544 BAudioInputI2S::dma,AudioInputI2S2::dma,AudioStream::memory_pool_available_mask,i2s_rx_buffer, andi2s2_rx_bufferA controlled build with the active
<Audio.h>include removed returned Blink toram=72352 Band selected zero Audio sources; SerialFlash also disappeared. Thus the Audio shim has a measured +192-byte RAM cost on Blink and intentionally makes the full Audio library visible to fbuild.APA102 versus Blink
On the same Teensy 4.1 target:
flash=100352 B,ram=72352 Bwithout the temporary Audio includeflash=157696 B,ram=86720 Bfbuild symbolsmap delta: approximately+70543 Bsymbol-level flash and+41504 B.bss.dmaThe new retained path is the Teensy 4.x Channel API:
fl::Channel::showPixels,fl::SpiChannelEngineAdapter,fl::ChannelManager,fl::ChannelEngineFlexIO,fl::BitBangChannelDriver,fl::ObjectFLED, and related channel-driver machinery.FASTLED_SPI_USES_CHANNEL_APIis still defaulted to1forFL_IS_TEENSY_4Xinsrc/FastLED.hlines 98–101.Remaining dependency leaks
The no-Audio A/B build still selected SdFat (46 sources), SD (1), and DmxSimple (1). These are independent of the Audio shim and should be investigated as fbuild LDF false positives or overly broad FastLED framework/header roots. SerialFlash selection is transitive from Audio’s
play_serialflash_raw.hpath.The desired invariant for a minimal Blink is that no Audio, SD/SdFat, SerialFlash, DmxSimple, or unrelated Channel API implementation is retained unless the sketch actually uses the corresponding feature.
This investigation is coordinated with FastLED/fbuild#1088; the Audio result there is intentional dependency discovery, but the measured Blink overhead should be considered in any follow-up design.
zackees commentedon Aug 20, 2026
Deferred after current-master verification. Teensy 4.1 APA102 is still 125,952 bytes and passes only because #2804 raised the ceiling to 165,000; FASTLED_SPI_USES_CHANNEL_API=1 still pulls the large Channel graph. Resolving this requires a Channel API/tree-shaking redesign, before/after symbol proof, restoration of the 88,000-byte ceiling, and an explicit ChannelManager opt-in path. Resume with Teensy hardware/size ownership for that redesign.
zackees commentedon Oct 7, 2026
Re-measured on master 7ac9a83 with
bash compile teensy41 --examples Apa102: 49,152 B flash, 28,448 B RAM. That is down from 148,476 B and well under the original 88,000 B ceiling; 3.10.3 measures 55,296 B on the same tooling.An
nmscan of the ELF finds noAsyncLog*,fl::net::http,ifstream,posix_filebuforstrerror. The onlyfl::tasksymbol isfl::task::run, which the generated main'sfl::delay(0)pulls in. The over-link is gone; #4710 and earlier work removed it.The
max_size_apa102: 165000band-aid incheck_teensy41_size.ymlcan now be tightened back toward 88000 (see docs/SIZE_THRESHOLD_HISTORY.md). Tracked in #4728.ci(size): restore teensy41 Apa102 ceiling 165000 -> 88000 (#2656 fixe…
fix(memory): stop fl::cin and PWM state from linking into every sketch (