Skip to content

fix(memory): reduce esp32c6 default flash/RAM usage (#4737) #4740

Closed

Description

@zackees

Context

Platform sub-issue of #4737. +75,304 B flash / +3,800 B RAM versus 3.10.3.

Source measurements, flash / RAM in bytes, fbuild 2.5.37, per-version source/examples and constant per-board build configuration. Reference SHAs: 3.10.3 20667c3a64, 3.10.6 ebf8c2823c, master 0c2e9f7300.

Pinned ESP32 framework: Arduino-ESP32 3.3.5 / ESP-IDF 5.5.1.

example 3.10.3 3.10.6 master reference
Blink 285400 / 14924 379686 / 20316 360704 / 18724

Execution workflow

Work one checklist item and one platform sub-issue at a time across the entire #4737 project, in the existing repository checkout without git worktrees. Use a feature branch in that checkout and reuse .build/fbuild/esp32c6, toolchain/dependency caches and test caches. Run builds sequentially. Verify changed source/flags are reflected in the ELF; use the appropriate wrapper's --clean only when stale-output evidence requires it. Record each completed item's measurements, checks and commit/PR before moving on.

Checklist

  • Reproduce this platform's current starting measurements with recorded SHA, flags and framework versions, and verify cache validity.
  • Create matched symbol/link-map evidence using bash bloat esp32c6; retain both the published example and controlled RGB-workload measurements where applicable.
  • Attribute default PARLIO engine flash, DMA/buffer sizing, channel objects and shared global state.
  • Optimize unused allocations, initialization and driver/encoder reachability; coordinate binding changes with Eliminate memory usage from dynamic driver binding. #4733.
  • Preserve default PARLIO timing, supported configurations, alternative-driver selection and network coexistence.
  • Land measured default flash and RAM reductions below the recorded master values for every example in this child, and quantify remaining gaps to 3.10.3.
  • Add a focused size regression check. For any implementation, capture a failing budget/reproduction before coding (RED) and the passing result afterward (GREEN); run relevant tests, lint and code review.
  • Ratchet applicable existing flash budgets and enforce RAM budgets through existing checks, preserving normal feature behavior and avoiding relaxed ceilings.
  • Publish final before/after bytes, remaining gaps, source SHA, commands, flags, framework versions and landed commit/PR links; update meta(memory): reduce default flash/RAM usage across all measured platforms #4737's platform scorecard.

Decisions

  • Default-build reductions are required; optional slim configurations supplement the work but do not satisfy this child.
  • Scope is this platform; shared fixes must be measured on affected siblings and tracked in the parent.
  • Any unmet reduction criterion needs an explicit maintainer-approved exception with exact bytes before closure.

Activity

  1. zackees commented on Oct 7, 2026

    @zackees
    MemberAuthor

    Summary

    • Share the mutually exclusive Wave3/Wave8 tables in PARLIO and build the nibble table only as a local during Wave8 initialization.
    • Preserve the existing high-performance byte lookup encoder, supported widths, SPI path, timing and ISR algorithms.
    • Add captured-waveform regression coverage for repeated mode switches and a scoped default C6 bloat budget.

    Refs #4740, #4737. Child closure follows landed-master verification and the cumulative performance comment; the meta issue stays open.

    Local measurements

    Same checkout, same cached C6 board project, fbuild 2.5.37, Arduino-ESP32 3.3.5 / IDF 5.5.1, GCC 14.2.0, normal board flags. Starting master e60f4fc; historical tag 3.10.3 at 20667c3. Historical generated stub uses ::delay(0) for compatibility. No worktrees.

    workload 3.10.3 flash / RAM starting master candidate saving
    published Blink 285392 / 14924 360688 / 18724 360494 / 18628 194 / 96
    controlled GPIO3, one RGB LED, no Serial 285392 / 14924 360422 / 18708 360228 / 18612 194 / 96

    The remaining gap versus 3.10.3 is 75102 / 3704 bytes for published Blink and 74836 / 3688 for the controlled workload. This is a measured reduction, not a claim of historical parity.

    Image-flash bloat metric falls 403928 → 403818; the new 403818 ceiling fails the starting master report and passes the candidate. Attributed RAM remains 29888 because sized symbol reporting omits the singleton storage; the <=2048-byte encoding-storage assertion guards this change separately (previous combined storage was 2144, RED). Board totals demonstrate the 96-byte actual static RAM reduction.

    Validation

    • Matched fbuild builds and bloat reports for 3.10.3/master/candidate, published and controlled workloads.
    • PARLIO full-path debug/sanitizer tests passed, including byte-for-byte DMA waveform across Wave3/Wave8/Wave3/Wave8.
    • bash test --cpp passed: 319/319 unit targets; cached examples validated by the wrapper.
    • bash lint and git diff --check passed; manual repository code review completed.
    • Logging audit: operational traces already use FL_LOG_PARLIO; remaining warnings describe invalid configuration/allocation/SDK failures. No fl::printf logging calls in PARLIO. Errors preserved.

    All platform validation is local. No CI Full invocation.

  2. zackees commented on Oct 7, 2026

    @zackees
    MemberAuthor

    C6 master minus 3.10.3 symbol ledger

    These are symbol-tool attributed buckets, not physical board RAM/flash totals. In particular, functions such as esp_cache_aligned_malloc_internal appear in the RAM bucket because of their output-region classification; their size is not an allocation. Singleton storage is missing from sized-symbol attribution. Actual board RAM is measured independently.

    The synthetic setup() attribution includes a large merged string/rodata pool; it does not establish that Blink's Serial banner itself added 50 KB. Controlled workload totals in PR #4749 isolate the example effect.

    Baseline: 3.10.3 20667c3a64; starting master e60f4fcf7f. Same C6 framework/configuration (Arduino 3.3.5, IDF 5.5.1), sequential fbuild builds and bash bloat esp32c6.

    Attributed RAM bucket

    • +2498 B: esp_cache_aligned_malloc_internal
    • +160 B: parlio_periph_signals
    • +126 B: __func__.2
    • +112 B: s_adc_cali_chan_compens
    • +88 B: range_read_addr_blocks
    • +83 B: __func__.3
    • +68 B: fl::ChannelEngineSpi::sSpiHostUsage
    • +64 B: fl::detail::kSpreadNibble
    • +54 B: __func__.4
    • +54 B: __func__.0
    • +50 B: __func__.1
    • +44 B: __FUNCTION__.11
    • +42 B: __FUNCTION__.18
    • +40 B: initial_gating_mode
    • +32 B: vtable for fl::(anonymous namespace)::DefaultMemoryResource
    • +32 B: vtable for fl::(anonymous namespace)::PSRamMemoryResource
    • +32 B: fl::asio::http::s_esp_route_contexts
    • +31 B: __FUNCTION__.10
    • +31 B: __func__.6
    • +31 B: __func__.15

    Attributed flash bucket

    • +50268 B: setup()
    • +4360 B: fl::detail::wave8_transpose_16x4_bf1_pipe4(unsigned char const*, unsigned char const*, unsigned char const*, unsigned char const*, unsigned char, unsigned char, unsigned char*, unsigned char*, unsigned char*, unsigned char*)
    • +3748 B: fl::detail::ParlioEngine::populateDmaBuffer(unsigned char*, unsigned int, unsigned int, unsigned int, unsigned int&)
    • +2638 B: fl::detail::ParlioEngine::initialize(unsigned int, fl::vector<int> const&, fl::ChipsetTimingConfig const&, unsigned int)
    • +2294 B: parlio_new_tx_unit
    • +1392 B: fl::detail::ParlioEngine::initializeSpi(fl::vector<int> const&, unsigned long, unsigned int)
    • +1354 B: fl::detail::wave8_transpose_8_bf1(unsigned char const*, unsigned char, unsigned char, unsigned char*)
    • +1304 B: fl::detail::wave8_transpose_4_bf1(unsigned char const*, unsigned char, unsigned char, unsigned char*)
    • +1202 B: fl::detail::wave8_transpose_16_bf1(unsigned char const*, unsigned char, unsigned char, unsigned char*)
    • +1190 B: fl::basic_string::write(char const*, unsigned int)
    • +1118 B: fl::detail::wave3_transpose_8(fl::Wave3Byte const*, unsigned char*)
    • +1050 B: parlio_tx_unit_transmit
    • +960 B: fl::wave3Transpose_16(unsigned char const (&) [16], fl::Wave3BitExpansionLut const&, unsigned char (&) [48])
    • +864 B: fl::ChannelManager::ChannelManager()
    • +856 B: fl::detail::ParlioEngine::beginTransmission(unsigned char const*, unsigned int, unsigned int, unsigned int)
    • +814 B: fl::detail::wave3_transpose_16(fl::Wave3Byte const*, unsigned char*)
    • +800 B: fl::detail::ParlioEngine::populateNextDMABuffer()
    • +780 B: fl::detail::ParlioEngine::allocateRingBuffers()
    • +720 B: fl::wave3Transpose_2(unsigned char const (&) [2], fl::Wave3BitExpansionLut const&, unsigned char (&) [6])
    • +686 B: fl::detail::ParlioEngine::workerIsrCallback(void*)
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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions