Swatantra-66 opened a new pull request, #22228:
URL: https://github.com/apache/nuttx/pull/22228

   ## Summary
   
   Addresses Issue [#20414](https://github.com/apache/nuttx/issues/20414) 
([HELP] Improve NuttX bloated size)
   
   Change `CONFIG_SERIAL_NPOLLWAITERS` default from `4` to `2` when 
`DEFAULT_SMALL=y`.
   
   On memory-constrained embedded systems (`DEFAULT_SMALL=y`), serial ports 
(such as console or telemetry UARTs) rarely, if ever, have more than two 
threads simultaneously polling or selecting on the same file descriptor.
   
   In `include/nuttx/serial/serial.h`, `struct uart_dev_s` carries an array of 
poll descriptor pointers:
   ```c
   FAR struct pollfd_s *fds[CONFIG_SERIAL_NPOLLWAITERS];
   ```
   Reducing `CONFIG_SERIAL_NPOLLWAITERS` from `4` to `2` eliminates two pointer 
entries per allocated serial device:
   - **32-bit architectures** (ARM Cortex-M, RISC-V 32, etc.): Saves **8 bytes 
of RAM** per UART device instance (e.g. `g_usart1dev` in `.data` / `.bss`).
   - **64-bit architectures**: Saves **16 bytes of RAM** per UART device 
instance.
   
   Standard configurations (`DEFAULT_SMALL=n`) retain the default of `4`.
   
   ### Code Size Impact
   
   Measured on `stm32f103-minimum:nsh` (`arm-none-eabi-gcc 10.3.1 -Os`, 
`DEFAULT_SMALL=y`):
   
   | Metric | Before (`SERIAL_NPOLLWAITERS=4`) | After 
(`SERIAL_NPOLLWAITERS=2`) | Delta |
   | :--- | :---: | :---: | :---: |
   | **Flash (text)** | 53,719 B | 53,711 B | **-8 B** |
   | **RAM (data)** | 344 B | 336 B | **-8 B** |
   | **RAM (bss)** | 3,136 B | 3,136 B | 0 B |
   | **Total Size** | 57,199 B | 57,183 B | **-16 B** |
   
   ## Impact
   
   - **Is new feature added?**: No.
   - **Is existing feature changed?**: Yes, defaults 
`CONFIG_SERIAL_NPOLLWAITERS` to `2` when `DEFAULT_SMALL=y`.
   - **Impact on user**: None. Targets requiring more concurrent poll waiters 
can explicitly set `CONFIG_SERIAL_NPOLLWAITERS` in their defconfig or 
menuconfig.
   - **Impact on build**: None.
   - **Impact on hardware**: Flash and RAM savings across all small embedded 
targets with serial drivers.
   - **Impact on documentation**: Updated 
`Documentation/os/drivers/character/serial.rst`.
   
   ## Testing
   
   Build host: Linux container (`nuttx-builder`) with `arm-none-eabi-gcc` 
10.3.1.
   Target board: `stm32f103-minimum:nsh` (`DEFAULT_SMALL=y`).
   
   ### 1. Style & Documentation Verification
   - `nxstyle include/nuttx/serial/serial.h`: PASSED (0 errors, 0 warnings).
   - `Documentation/os/drivers/character/serial.rst`: documentation updated and 
consistent.
   
   ### 2. Kconfig Default Verification
   - Under `DEFAULT_SMALL=n` (`sim:nsh`): `CONFIG_SERIAL_NPOLLWAITERS=4`.
   - Under `DEFAULT_SMALL=y` (`stm32f103-minimum:nsh`): 
`CONFIG_SERIAL_NPOLLWAITERS=2`.
   
   ### 3. Build & Size Comparison Logs
   
   **Before (`CONFIG_SERIAL_NPOLLWAITERS=4`):**
   ```
   CP: arch/dummy/Kconfig to /repos/nuttx/arch/dummy/dummy_kconfig
   CP: boards/dummy/Kconfig to /repos/nuttx/boards/dummy/dummy_kconfig
   LN: platform/board to /repos/apps/platform/dummy
   Register: nsh
   Register: sh
   LD: nuttx
   CP: nuttx.bin
      text         data     bss     dec     hex filename
     53719          344    3136   57199    df6f nuttx
   ```
   
   **After (`CONFIG_SERIAL_NPOLLWAITERS=2`):**
   ```
   LD: nuttx
   CP: nuttx.bin
      text         data     bss     dec     hex filename
     53711          336    3136   57183    df5f 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]

Reply via email to