Skip to content

fix(memory): reduce uno default flash/RAM usage (#4737) #4742

Closed

Description

@zackees

Context

Platform sub-issue of #4737. Blink: +1,374 B flash / +498 B RAM. Apa102: +504 B flash / +139 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.

example 3.10.3 3.10.6 master reference
Blink 3784 / 131 5166 / 633 5158 / 629
Apa102 3178 / 187 4510 / 505 3682 / 326

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/uno, 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 uno; retain both the published example and controlled RGB-workload measurements where applicable.
  • Separate Blink's Serial/banner and AVR string-storage costs from library overhead; retain Apa102 as the no-banner comparison.
  • Shrink controller settings/optional white-channel, gamma and color-profile storage, vtables and shared controller/global state; coordinate with AVR: remaining Nano sketch growth vs 3.10.3 (+1.5 KB flash, +137 B RAM) and the RGBW power-estimate opt-in #4735.
  • Preserve explicitly used serial, RGB/RGBW/RGBWW and power-limiter behavior; keep unused Serial unlinked in sketches that do not open a port.
  • 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

    Landed PR #4751 at d9cc468d5cea767ce59ce7d94566f44c2ce045d5. Fresh builds and scoped budgets from master pass; production sources/tests/budgets are identical to candidate 81c9a6f694 (verified with git diff).

    All entries are fbuild board flash / board RAM bytes:

    workload 3.10.3 starting master landed master saved flash / RAM gap to 3.10.3
    Blink 3784 / 131 5158 / 629 5138 / 443 20 / 186 +1354 / +312
    Apa102 3178 / 187 3682 / 326 3650 / 324 32 / 2 +472 / +137
    controlled RGB 3784 / 131 3942 / 268 3922 / 266 20 / 2 +138 / +135

    Starting master 28a41d619f; historical source 20667c3a64. fbuild 2.5.37, AVR GCC 7.3.0-atmel3.6.1-arduino7, Arduino AVR core 5.4.0, ATmega328P 16 MHz. Same normal flags and .build/fbuild/uno cache/project, sequential local builds, no worktrees or CI Full. Historical source/examples were archived into the same project with a ::delay(0) generated stub solely for the missing historical fl::delay API. Controlled workload is one NEOPIXEL at GPIO3, red/black show +1000-ms delay, no Serial.

    The exact reordered product removes 22 B __muluhisi3; Apa102's adjustment function shrinks another 10 B. Controller storage shrinks 2 B through one-byte RGBW selector fields with unchanged named values. Blink's 186 B banner saving uses AVR flash printing and preserves every original byte, including CRLF/UTF-8 marker and header/status timing relative to addLeds. Explicit Serial remains in Blink and stays absent from Apa102/control symbol reports. No fields, white modes, serial, gamma/color-profile, power-limiter or output features removed. Rebuild application/library together after selector ABI/layout change.

    Budget metrics are separately image flash / attributed RAM, not board RAM: Blink 5158/624 →5138/438; Apa102 3682/292 →3650/290; controlled 3942/262 →3922/260. Original reports are RED against both new budgets; candidate/landed CLI checks GREEN. Existing Uno workflow/frozen flash ceilings lowered to 5138/3650 B. No ceiling raised, no workflow added.

    Independent 64-bit reference checks every correction/temperature pair at five boundary brightnesses under sanitizers; also passed original arithmetic. Selector-size RED/debug then GREEN captured. Local full native gate passes 319/319 unit targets and 95/95 host examples; lint and manual code review pass. All ordinary PR checks green; CodeRabbit remained pending without findings at merge, so no AI approval is claimed.

    Shared changes measured locally on completed siblings: C3 published 403210/68540 →403182/68524; C6 360474/18612 →360434/18612; STM32 26356/3480 →26324/3472. Controlled equivalents also improve; their ceilings ratcheted. Fresh translation-unit rebuilds reject stale outputs (one restored STM32 sketch reused a controlled ELF; that result was rejected and a fresh published build verified). Full report/log/ledger/source-hash evidence retained under .build/memory-4737/uno/, with reproducing commands and shared toolchain pins in the PR.

    AVR logging audit finds no fl::printf logging. Remaining FL_WARN sites describe invalid inputs, allocation failure or unsupported operations and are absent in default small-memory builds; preserve those diagnostics. RMT/PARLIO reductions remain in earlier children.

    Both published examples and controlled library workload now have positive default flash/RAM reductions. Remaining historical gaps are quantified, so this child can close. The cumulative parent diff includes shared savings; #4737 stays open.

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