Context
JsonLogger (core/utils/JsonLogger.h) serializes every write behind m_mutex and writes synchronously to an std::ofstream. Any thread that logs, including strategy and market data paths when --json-log is enabled, pays mutex contention plus file I/O on the calling thread. The docs were recently corrected to say exactly this (PR #73), but the better fix is removing the overhead.
What to do
- Move serialization and file I/O to a dedicated writer thread fed by a bounded queue (an SPSC or MPSC ring buffer fits the existing lock-free style of the codebase).
- Define overflow behavior explicitly (drop with a counter, or block) so the hot path never does unbounded work.
- Flush and drain the queue on shutdown so no events are lost on clean exit.
- Add a benchmark comparing log-call latency before and after.
Notes
After this lands, update the JSON Data Export doc's thread-safety wording again to describe the async design.
Context
JsonLogger(core/utils/JsonLogger.h) serializes every write behindm_mutexand writes synchronously to anstd::ofstream. Any thread that logs, including strategy and market data paths when--json-logis enabled, pays mutex contention plus file I/O on the calling thread. The docs were recently corrected to say exactly this (PR #73), but the better fix is removing the overhead.What to do
Notes
After this lands, update the JSON Data Export doc's thread-safety wording again to describe the async design.