Repository navigation
libc/stdio: Batch vsprintf output - #21072
Merged
Merged
Conversation
Write consecutive literal format text with one stream call when ROMGETC is not required, reducing per-character output overhead on printf hot paths. Signed-off-by: chao an <[email protected]>
|
Emit repeated spaces and zeroes in small fixed-size chunks to avoid calling the output callback once per padding character. Signed-off-by: chao an <[email protected]>
xiaoxiang781216
approved these changes
Oct 29, 2026
acassis
approved these changes
Oct 30, 2026
Contributor
|
@anchao please analyze the CI issues |
This was referenced Oct 30, 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
This PR optimizes the hot
vsprintf()formatting path used by printf/syslog-style output.It contains two changes:
CONFIG_ARCH_ROMGETCis not required.These reduce per-character output callback overhead in common formatting paths, especially for log/printf output with long literal text or wide field padding.
Motivation
vsprintf_internal()currently emits many parts of the formatted output one character at a time vialib_stream_putc(). For printf/syslog hot paths, this means repeated function-pointer-style output calls for:The formatted result is unchanged, but batching these output sequences can reduce call overhead.
Implementation
Literal text batching
For non-
CONFIG_ARCH_ROMGETCbuilds, consecutive literal characters in the format string are now accumulated and emitted with onestream_puts()call.The
CONFIG_ARCH_ROMGETCpath keeps the original character-by-character behavior because format characters may need to be fetched throughup_romgetc().Padding batching
Repeated spaces and zeroes are emitted through a small helper that writes from static 16-byte buffers:
" ""0000000000000000"Padding loops now output chunks rather than calling
stream_putc()for each byte.Testing
sim/nsh