Printf Debugging at 1ns: High-Performance C++ Logging Without Locks
summary
Claims a lock-free, system-call-free C++ logger (L3) that records entries at 1 nanosecond per entry by using an atomically incremented index into an mmap-backed lock-free buffer and writing pointer-sized descriptors instead of formatted strings. Logs scale across cores without mutex contention, recover original text by post-processing RO data section offsets to map pointers back to strings, and a single-thread fast-path saves roughly 10 ns. Full source and docs on GitHub.
AI-written summary · about
chapters (9)
- 0:00Why printf debugging is problematic
- 0:36Limitations of standard printf and fprintf
- 1:16Performance bottlenecks in multithreaded logging
- 1:59Exploring alternatives: speedlog and sprintf
- 2:30Designing a lock-free logging buffer
- 3:10Using mmap to eliminate system calls
- 3:50Optimizing further: pointer-based logging
- 4:36Post-processing logs from RO data sections
- 5:00Final thoughts and future improvements
related talks
55m “High Performance C++ Concurrent Transactional Data Structures"
30mLet's Intercept OpenGL Function Calls...for Logging!
01h 11mLock-Free Programming (or, Juggling Razor Blades), Part II
01h 05mHow to Write a Heap Memory Profiler
55mAbusing Your Memory Model for Fun and Profit
01h 32mLock-free programming with modern C++
01h 30mTuning C++: Benchmarks, and CPUs, and Compilers! Oh My!
57mModern Linux C++ debugging tools - under the covers
