Skip to content

perf(avr): move remaining large stack buffers (readLine, SerialPort::printf, digitalMultiWrite, noise) off the stack #5307

Closed

Description

@zackees

Depends on #5305.

Problem

Other large stack consumers on small-RAM targets (avr-gcc -fstack-usage, ATmega328P):

AVR frame where
2·W·H B dynamic (512 B @16x16) fill_2dnoise8/16, fill_noise8/16 via FASTLED_STACK_ARRAY — src/noise.cpp.hpp:881-965
654 B fl::readLine 512 B nativeBuf — src/fl/stl/cstdio.cpp.hpp:191
256 B in every caller SerialPort::printf — src/fl/system/serial.h:288
1196 B / 604 B digitalMultiWrite16/8 — src/fl/system/pins.cpp.hpp:380/263

Proposed solution

  • Move fixed-size buffers (readLine; SerialPort::printf — also move the buffer out of the inline header so it isn't duplicated per caller; digitalMultiWrite*) to fl::scratch<T>, or shrink them where the size is arbitrary.
  • Noise VLAs are runtime-sized; keep FASTLED_STACK_ARRAY unless a runtime-sized scratch stays simple. Document the decision.
  • Document how to rerun the AVR stack inventory (or extend ci/codec_memory/audit.py, which already parses -fstack-usage).
  • Out of scope: big-target-only users (SingletonThreadLocal<fl::vector> scratch in blur/channel/FFT, StbvTempBuffer, codecs, net/http).

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: avrsanitizedtype: feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions