4 ms·
In a lockfree data structure, how do you ensure GC stalls never happen in the real-time code? I write a lot of lockfree C++ that requires 100 nanosecond-magnit
by CoolGuySteve 8y ago
In a lockfree data structure, how do you ensure GC stalls never happen in the real-time code?
I write a lot of lockfree C++ that requires 100 nanosecond-magnitude latencies 100% of the time. But in doing so, my algorithms are always implemented with a cache coherent wait-free allocator pool as well.
I don’t see how you can achieve the same thing in a GC language without a lot of manual tuning or a similar memory pool design.
- ridiculous_fish 8y agoIf you need sub-microsecond latencies then the requirements can be summarized as "don't allocate, don't deallocate." Now the memory management technique is irrelevant, because the goal is to avoid memory management at all costs. Yes you'll need a memory pool design in whatever language. But most GC'd languages only collect at allocation sites, and so if you don't allocate you won't trigger a GC.
- pjmlp 8y agoMultiple options are possible depending on the language. 1 - Disabling the GC altogether during access to the data structure 2 - Ensuring that the GC wont run during the region (TryNoGCRegion() in .NET or a real-time thread in Real-Time Java) 3 - Or if the language supports it, keep part of the structure away from the GC, using RAII to keep track of the blocks