kamcheungting-db opened a new pull request, #795:
URL: https://github.com/apache/iceberg-cpp/pull/795
Makes the logging **format → dispatch path allocation-free**, addressing the
zero-allocation request on #725. Builds on the merged logging blocks
(#722/#723/#724).
**What changed**
- Sinks now receive a non-owning `LogRecord` (`{ level, std::string_view
message, std::source_location, std::span<const LogAttribute> }`) instead of an
owned `LogMessage&&`. The views are valid only for the duration of the `Log()`
call.
- The function-style `Log()` / `FormatAndEmit` format into a reused
per-thread `FormatBuffer()` via `std::format_to` (`clear()` keeps capacity), so
logging performs **no heap allocation after the buffer warms up**.
`std::format_to` with a `std::format_string` keeps compile-time format-string
checking.
- `LogMessage`/`Builder` stay as the owned/retained type and convert
implicitly to `LogRecord`, so `logger->Log(builder.Build())` is unchanged.
- Synchronous sinks (`CerrLogger`, no-op) read the view directly with no
allocation; retaining sinks (the test `CapturingLogger`) deep-copy into an
owned `LogMessage`, so existing assertions are unaffected.
**Why now**: every production sink consumes the record synchronously, so the
owned-`std::string` model wasn't buying anything in practice — better to change
the interface before external adoption.
**Tests**: new `logging_zero_alloc_test` (its own binary; global `operator
new` counter + a negative control proving the probe works) asserts the
format→dispatch path does 0 heap allocations after warmup. Existing logging
tests pass unchanged; ASan/TSan clean.
**Out of scope (documented)**: `CerrLogger`'s own rendered-line
`std::format` and `ICEBERG_LOG_RUNTIME_FMT` (vformat) still allocate.
The open macro/spdlog/registry PRs (#725/#726/#737) will be rebased onto
this interface once it lands.
This pull request and its description were written by Isaac.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]