Understand the performance tradeoffs of reckless
masterWhen choosing reckless, be aware of its intentional design tradeoffs compared to other logging libraries:
- Dangling Pointers:
recklessallows you to pass raw pointers to the background thread. This improves performance because the log string is not prepared at the call site, but it can lead to crashes if the pointer becomes invalid before it is written to disk.- Best Practice: Never use raw pointers to dynamically allocated or stack-allocated memory. Pointers to global objects and string literals are generally safe. For dynamically allocated strings, use
std::string.
- Best Practice: Never use raw pointers to dynamically allocated or stack-allocated memory. Pointers to global objects and string literals are generally safe. For dynamically allocated strings, use
- Floating-Point Precision:
recklessmay trade some precision in floating-point output for increased performance. - Latency vs. Throughput:
recklessaims for stable, low latency. It uses a configurable buffer (defaulting to 64 KiB) to avoid sudden hangs. If the buffer fills up, the caller may experience latency spikes as the logger performs synchronous writes. - Crash Safety:
recklessis designed to minimize the risk of losing log messages during a crash by flushing whenever possible.