From be9e13915ddd32ae980d1b6e0cb58fafe9599f45 Mon Sep 17 00:00:00 2001 From: nmzik Date: Wed, 21 Oct 2026 03:49:57 +0200 Subject: [PATCH] log: format LOGF output out of line so small guest fiber stacks do not reserve it --- src/common/logging/log.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/common/logging/log.h b/src/common/logging/log.h index d332d96f4..ac56659af 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -51,20 +51,26 @@ inline constexpr auto BrightWhite = fmt::fg(fmt::terminal_color::bright_white) } // namespace Color +// Out of line, so callers on small guest stacks (fibers) do not reserve the formatting frame. +template +[[gnu::noinline]] void Printf(fmt::text_style style, const char* format, const Args&... args) { + Write(style, fmt::sprintf(format, args...)); +} + } // namespace Log // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define LOGF(...) \ do { \ if (!::Log::IsSilent()) { \ - ::Log::Write(::fmt::sprintf(__VA_ARGS__)); \ + ::Log::Printf({}, __VA_ARGS__); \ } \ } while (false) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define LOGF_COLOR(style, ...) \ do { \ if (!::Log::IsSilent()) { \ - ::Log::Write((style), ::fmt::sprintf(__VA_ARGS__)); \ + ::Log::Printf((style), __VA_ARGS__); \ } \ } while (false)