Loading src/quic.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -45,8 +45,22 @@ #include <cmath> #include <mutex> // Cached once (mirrors ensureQuicPerfReporterStarted()'s "single getenv() // call and nothing else" pattern below): callgrind profiling of a bulk // transfer showed getenv("QUIC_TRACE") re-queried on every single QUIC_DBG // call -- and there are 61 call sites, several in the per-packet hot path // (sendPacket, processApplicationPacketsBatch, unprotectPacket) -- becoming // the single largest cost in the whole program (~18% of instructions) once // an unrelated per-packet memset elsewhere was fixed. The environment // variable can't change once the process has started, so checking it any // more than once is pure waste. inline bool quicTraceEnabled() { static const bool enabled = (getenv("QUIC_TRACE") != nullptr); return enabled; } #define QUIC_DBG(fmt, ...) do { \ if (getenv("QUIC_TRACE")) { \ if (quicTraceEnabled()) { \ fprintf(stderr, "[%.6f] " fmt "\n", \ std::chrono::duration<double>(std::chrono::steady_clock::now().time_since_epoch()).count(), ##__VA_ARGS__); \ } \ Loading Loading
src/quic.cpp +15 −1 Original line number Diff line number Diff line Loading @@ -45,8 +45,22 @@ #include <cmath> #include <mutex> // Cached once (mirrors ensureQuicPerfReporterStarted()'s "single getenv() // call and nothing else" pattern below): callgrind profiling of a bulk // transfer showed getenv("QUIC_TRACE") re-queried on every single QUIC_DBG // call -- and there are 61 call sites, several in the per-packet hot path // (sendPacket, processApplicationPacketsBatch, unprotectPacket) -- becoming // the single largest cost in the whole program (~18% of instructions) once // an unrelated per-packet memset elsewhere was fixed. The environment // variable can't change once the process has started, so checking it any // more than once is pure waste. inline bool quicTraceEnabled() { static const bool enabled = (getenv("QUIC_TRACE") != nullptr); return enabled; } #define QUIC_DBG(fmt, ...) do { \ if (getenv("QUIC_TRACE")) { \ if (quicTraceEnabled()) { \ fprintf(stderr, "[%.6f] " fmt "\n", \ std::chrono::duration<double>(std::chrono::steady_clock::now().time_since_epoch()).count(), ##__VA_ARGS__); \ } \ Loading