Repository navigation
libs/libc/stdio: disable stdio buffering by default on DEFAULT_SMALL - #22251
Open
Swatantra-66 wants to merge 1 commit into
Open
Swatantra-66 wants to merge 1 commit into
Swatantra-66 wants to merge 1 commit into
Conversation
Tiny and memory-constrained embedded systems (DEFAULT_SMALL=y) benefit greatly from disabling standard I/O buffering to minimize both Flash and runtime SRAM footprints. When CONFIG_STDIO_DISABLE_BUFFERING=y: 1. Sched/TLS eliminates the per-task stdout buffer allocation (CONFIG_STDIO_BUFFER_SIZE = 64+ bytes heap RAM saved per active task). 2. Libc strips stream buffer allocation, deallocation, flushing, and ring-buffer maintenance routines (lib_setbuf, lib_setvbuf, lib_libfflush, lib_rdflush_unlocked, lib_wrflush_unlocked, etc.). Change CONFIG_STDIO_DISABLE_BUFFERING to default to DEFAULT_SMALL instead of n. Standard configurations (DEFAULT_SMALL=n) retain full buffering. Size reduction measured on stm32f103-minimum:nsh (arm-none-eabi-gcc 10.3.1 -Os): - Flash (text): 53,711 -> 53,255 B (-456 B) - RAM (data): 336 -> 332 B (-4 B) - Total Image: 57,183 -> 56,723 B (-460 B) - Heap RAM: 64 bytes saved per created task Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Swatantra Yadav <maverickswatantra@gmail.com>
xiaoxiang781216
approved these changes
Nov 24, 2026
1 task done
jerpelea
approved these changes
Nov 24, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses Issue #20414 ([HELP] Improve NuttX bloated size)
Change
CONFIG_STDIO_DISABLE_BUFFERINGdefault fromnto DEFAULT_SMALL in libs/libc/stdio/Kconfig.Tiny and memory-constrained embedded profiles (
DEFAULT_SMALL=y) benefit significantly from disabling stdio stream buffering:sched/tls/task_initinfo.c, every task startup allocatesCONFIG_STDIO_BUFFER_SIZE(default 64 bytes) for stdout buffering (info->ta_buf). When buffering is disabled, this allocation is completely eliminated, saving 64 bytes of heap RAM for every thread/task in the system.libs/libc/stdio, disabling buffering allows the compiler to strip stream buffer allocation, deallocation, flushing, and ring-buffer maintenance routines (setbuf,setvbuf,setbuffer,lib_libfflush,lib_rdflush_unlocked,lib_wrflush_unlocked, and stream flush logic).Standard configurations (
DEFAULT_SMALL=n) retain the default ofn(full buffering enabled).Code Size Impact
Measured on
stm32f103-minimum:nsh(arm-none-eabi-gcc 10.3.1 -Os):STDIO_DISABLE_BUFFERING=n)STDIO_DISABLE_BUFFERING=y)Impact
CONFIG_STDIO_DISABLE_BUFFERINGtoDEFAULT_SMALL.DEFAULT_SMALL=ytargets, saves 456 bytes of Flash and 64 bytes of heap RAM per task automatically without manual defconfig tuning. Over 40 defconfigs already manually setCONFIG_STDIO_DISABLE_BUFFERING=y. Standard builds (DEFAULT_SMALL=n) are unaffected.Testing
Build host: Linux container (
nuttx-builder) witharm-none-eabi-gcc10.3.1.Target board:
stm32f103-minimum:nsh.1. Kconfig Default Verification
DEFAULT_SMALL=n:CONFIG_STDIO_DISABLE_BUFFERING=n.DEFAULT_SMALL=y:CONFIG_STDIO_DISABLE_BUFFERING=y.2. Build & Size Comparison Logs
Before (
CONFIG_STDIO_DISABLE_BUFFERING=n):After (
CONFIG_STDIO_DISABLE_BUFFERING=y):