Non-blocking logging from the audio thread

Captain's Log: Stardate 77530.5

Today I finished up work on Delay Lines. They were working well as of the last update, but there were a few edge-cases that needed to be addressed, having to do with what happens when Sensors are created or removed. When new Sensors come into existence, it's important that Delay Lines reading from them don't read old data, say, from the previous Sensor to which that memory space was allocated. And furthermore, it's important that when things shift around in memory, the mappings between Sensor objects and their delay sample buffers are stable. I made sure that both of these work in sane ways and tested it.

After that, I needed an easy project, so I started working on replacing the debug logging system, which is a long-standing TODO before releasing Anukari. Today I'm using the Abseil library, since I liked it when I worked at Google. But I always knew I'd have to replace it, because it allocates memory.

I looked into all the "fast, lightweight, etc" logging libraries out there, like spdlog and llcpp. Sadly, none of them meet my requirements of zero allocation and wait-free asynchronous logging. The closest one is spdlog, but they dropped their MPSC async logging support and put in a mutex, because they didn't want a busy wait in their flush thread.

Sigh, so I'm implementing a logging library myself. Fortunately, libfmt makes the formatting part really easy, and it guarantees no allocation when you ask it to. So really this is not that big of a project, and I'm already mostly done with the library. Porting all the existing code will be a bit of a hassle, because Abseil uses operator<< and now I'll be moving to std::format -type strings. But it will be worth it so that I can log from the audio thread with impunity.


© 2024 Anukari LLC, All Rights Reserved
Contact Us|Legal