Skip to content

perf: shrink DigitalMultiWrite8/16 nibble LUTs (592/1184 B on AVR, ~1.3/2.6 KB on 32-bit) #5314

Closed

Description

@zackees

Follow-up to #5307 / #5313.

Problem

DigitalMultiWrite8 / DigitalMultiWrite16 (src/fl/system/pins.h) store their nibble LUTs as PinList { int pins[4]; u8 count; } arrays: 64 / 128 entries. Object size:

AVR (int = 2 B) 32-bit (padded to 20 B/entry)
DigitalMultiWrite8 592 B ~1312 B
DigitalMultiWrite16 1184 B ~2624 B

#5313 removed these objects from the stack of the one-shot digitalMultiWrite8/16 free functions. Long-lived instances still pay this cost, for example BitbangChannelDriver::mMultiWriter (src/platforms/shared/bitbang/bitbang_channel_driver.h), and so does any user code that keeps a writer as a member or a local.

Proposed solution

Shrink the representation and keep the writeByte() hot path's digitalWrite sequence. Options:

  • Store LUT entries as 2-bit indices into mPins (a u8 per nibble value for the set mask plus the count), so each group needs 16 B of LUT plus 4 pins.
  • Drop the LUT and test bits directly, as the free functions now do. This needs a timing check with the AutoResearch writeByte benchmark (examples/AutoResearch/AutoResearchRemoteBenchmarkMethods.cpp) on a bitbang target, because the bitbang clockless timing depends on it.

Acceptance: object size and writeByte timing are measured before and after on AVR and on an ESP32 or RP2040 bitbang target, and the pin states and write order are unchanged (the tests in tests/fl/system/pin.cpp already compare the classes against the free functions).

Activity

  1. added
    sanitized
    on Nov 20, 2026
  2. moved this from Triage to Done in FastLED Trackeron Nov 20, 2026
  3. added a commit that references this issue on Nov 20, 2026
    be3cf27
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

    sanitized

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions