Skip to content

perf(channels): per-frame fl::string driver keys and name lookups in driver paths (2.8-6 KB) #4799

Closed

Description

@zackees

Problem

The driver paths build and copy fl::strings at runtime: about 2.8–6 KB of string, vector and log code per ESP32 sketch versus 3.10.3.

  • Per-frame key: SlimSpiBridgeController::resolveDriver() (src/fl/channels/slim_spi_bridge_controller.h:160) builds a fl::string busKey every frame and looks drivers up by name. showPixels() also calls isDriverEnabled(driver->getName().c_str()) per frame.
  • Name lookups: channel_manager_esp32.cpp.hpp does findDriverByName(fl::string::from_literal(...)).
  • Symbols linked: basic_string::write (856 B on S3), materialize (305), copy (185/155), vector_basic::grow_to, log_emit_prefix, itoa/utoa32.

Proposed fix

Identify drivers by a small integer or enum ID, or by const char* literal compared by pointer or strcmp, instead of fl::string. Cache the resolved driver in the controller and invalidate it on registry change.

Acceptance

  • No fl::string construction in the per-frame show path.
  • The string symbols above shrink in the Blink and APA102 maps.
  • Driver enable/disable and exclusive-driver tests pass.

Data: https://fastled.github.io/dashboard/ (master 18669e6 vs 3.10.3, fbuild 2.5.38), symbol-level bloat reports linked from each dashboard point.

Activity

  1. added
    type: regression
    priority: medium
    area: core
    on Oct 9, 2026
  2. zackees commented on Oct 9, 2026

    @zackees
    MemberAuthor

    Investigated during the #4801 pass (esp32dev/esp32s3); deferred to the structural work in #4800.

    The call graph on current master (esp32dev Blink) shows the fl::string core (materialize, copy, the StringHolder variant) is reachable through every IChannelDriver::getName(), which returns fl::string (e.g. ChannelEngineRMT::getName → string::from_literal). It is also reachable through c_str() and string_n<32> users outside the driver path. Removing only the per-frame busKey in SlimSpiBridgeController::resolveDriver() saves CPU per frame but not measurable flash. The flash win needs driver identity to become an enum/ID (or const char*) across IChannelDriver, ChannelManager lookups and isDriverEnabled, which is an API change better done with #4800's channels slimming.

  3. zackees commented on Oct 9, 2026

    @zackees
    MemberAuthor

    Per-frame string work in the show paths is fixed by #4820: ChannelManager::isDriverEnabled(const IChannelDriver&) matches by instance, used by SlimBridgeController, SlimSpiBridgeController and the Teensy 4 block controller. The remaining flash-oriented part, a driver identity API change, is split into #4821.

  4. moved this from Triage to Done in FastLED Trackeron Oct 9, 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

    area: corepriority: mediumtype: regression

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions