Swatantra-66 opened a new pull request, #22251: URL: https://github.com/apache/nuttx/pull/22251
## Summary Addresses Issue [#20414](https://github.com/apache/nuttx/issues/20414) ([HELP] Improve NuttX bloated size) Change `CONFIG_STDIO_DISABLE_BUFFERING` default from `n` to DEFAULT_SMALL in libs/libc/stdio/Kconfig. Tiny and memory-constrained embedded profiles (`DEFAULT_SMALL=y`) benefit significantly from disabling stdio stream buffering: 1. **Heap RAM Savings (64+ bytes per task)**: In `sched/tls/task_initinfo.c`, every task startup allocates `CONFIG_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. 2. **Flash Code Savings (-456 bytes)**: In `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 of `n` (full buffering enabled). ### Code Size Impact Measured on `stm32f103-minimum:nsh` (`arm-none-eabi-gcc 10.3.1 -Os`): | Metric | Before (`STDIO_DISABLE_BUFFERING=n`) | After (`STDIO_DISABLE_BUFFERING=y`) | Delta | | :--- | :---: | :---: | :---: | | **Flash (text)** | 53,711 B | 53,255 B | **-456 B** | | **RAM (data)** | 336 B | 332 B | **-4 B** | | **RAM (bss)** | 3,136 B | 3,136 B | 0 B | | **Total Size** | 57,183 B | 56,723 B | **-460 B** | | **Heap per Task** | 64 B allocated | 0 B allocated | **-64 B / task** | ## Impact - **Is new feature added?**: No. - **Is existing feature changed?**: Yes, defaults `CONFIG_STDIO_DISABLE_BUFFERING` to `DEFAULT_SMALL`. - **Impact on user**: On `DEFAULT_SMALL=y` targets, saves 456 bytes of Flash and 64 bytes of heap RAM per task automatically without manual defconfig tuning. Over 40 defconfigs already manually set `CONFIG_STDIO_DISABLE_BUFFERING=y`. Standard builds (`DEFAULT_SMALL=n`) are unaffected. - **Impact on build**: None. - **Impact on hardware**: Flash and RAM savings across all memory-constrained targets. - **Impact on documentation**: None. ## Testing Build host: Linux container (`nuttx-builder`) with `arm-none-eabi-gcc` 10.3.1. Target board: `stm32f103-minimum:nsh`. ### 1. Kconfig Default Verification - Under `DEFAULT_SMALL=n`: `CONFIG_STDIO_DISABLE_BUFFERING=n`. - Under `DEFAULT_SMALL=y`: `CONFIG_STDIO_DISABLE_BUFFERING=y`. ### 2. Build & Size Comparison Logs **Before (`CONFIG_STDIO_DISABLE_BUFFERING=n`):** ``` LD: nuttx CP: nuttx.bin text data bss dec hex filename 53711 336 3136 57183 df5f nuttx ``` **After (`CONFIG_STDIO_DISABLE_BUFFERING=y`):** ``` LD: nuttx CP: nuttx.bin text data bss dec hex filename 53255 332 3136 56723 dd93 nuttx ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
