tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.53k stars 726 forks source link

Is the formatter on fields invoked even if log-level is not in effect? #3077

Closed thomaseizinger closed 2 months ago

thomaseizinger commented 2 months ago

During profiling of my application, I noticed that ~1% of a fairly hot function was spent in alloc::fmt::format::format:

image

The particular function is implemented here: https://github.com/firezone/firezone/blob/947db254cc968ca0f4112d0aa54f78b3131700c6/rust/connlib/tunnel/src/io.rs#L138-L158

At the time of benchmarking, only the INFO level was active.

Is it possible that tracing invokes the formatter of fields despite their level not being active?

thomaseizinger commented 2 months ago

False alarm, turned out to be something else.