Skip to content

perf(stl): trim vector_element_ops table (drop swap/destroy, shared uninitialized_move_n) ~0.8 KB #4794

Closed

Description

@zackees

Problem

fl::vector<T> is already type-erased: vector_basic plus one static vector_element_ops table per non-trivial T (src/fl/stl/basic_vector.h:21,312). Every table stores every operation, though, so all of them are emitted for each non-trivial T even when that T never uses them.

Measured on master (flash):

esp32dev Blink esp32s3 SPI teensy41 Blink
Shared vector_basic 1,084 1,362 496
Per-type ops-table functions 1,570 969 710
Per-type vector<T> wrappers 1,062 883 288

The esp32dev ops-table cost by operation is swap 567, destroy/destroy_n 377, uninitialized_move_n 224, copy 151, move 132, default 119. The largest types are ChannelEngineRMTImpl::PendingChannel/ChannelState (~300 each), DriverInfo 271, shared_ptr<ChannelData> 259, ChannelManager::EngineEntry 222 and task::Handle 213.

Proposed fix

  • Remove swap_elements. The only use is the inline-buffer vector swap (basic_vector.cpp.hpp:384), which can use move_construct + destroy through a temporary.
  • Remove destroy in favor of destroy_n(p, 1).
  • Implement uninitialized_move_n once in vector_basic as a loop over move_construct.

Acceptance

  • About 0.8 KB less flash per ESP32 sketch, with no runtime regression in bash test vector tests or bash profile on hot vector paths.
  • Low priority; post-release.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corepriority: low

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions