-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util/backtrace: Optimize formatter to reduce memory allocation overhead
This commit addresses a critical memory allocation issue in backtrace formatting by directly specializing fmt::formatter for backtrace types, eliminating dependency on iostream-based formatting. Problem: When Seastar applications experience high memory pressure, logging backtrace information could fail due to additional memory allocation required by iostream formatting. This resulted in errors like: ``` ERROR 2024-12-10 01:59:16,905 [shard 0:main] seastar_memory - seastar/src/core/memory.cc:2126 @void seastar::memory::maybe_dump_memory_diagnostics(size_t, bool): failed to log message: fmt='Failed to allocate {} bytes at {}': std::__ios_failure (error iostream:1, basic_ios::clear: iostream error)" ``` Solution: - Implement direct fmt::formatter specialization for backtrace - Remove reliance on operator<< for string representation - Reduce memory allocation pressure during out-of-memory scenarios - Improve reliability of backtrace logging under extreme memory constraints Compatibility Improvements: - Ensure consistent `fmt::formatter` availability across fmt library versions - Deprecate two `simple_backtrace` constructors previously added in 095a07b, as they are no longer needed with fmt::join - Maintain robust formatting approach independent of library version Impact: This change enhances system resilience by enabling backtrace logging even under significant memory pressure, providing more reliable post-mortem debugging information. Signed-off-by: Kefu Chai <[email protected]>
- Loading branch information
Showing
2 changed files
with
71 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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