3 ms·
Nimrod's GC is perfect for real-time software like games. It uses a deferred reference counting algorithm which can have pause times as small as 1ms. How does
by codexon 13y ago
Nimrod's GC is perfect for real-time software like games. It uses a deferred reference counting algorithm which can have pause times as small as 1ms.
How does Nimrod deal with the multi-thread reference counting performance problem?
Languages like Java don't use ref count and CPython has a global lock because multiple threads accessing a ref count mutex kills performance.
- rayiner 13y agoDeferred reference counting (DRC) doesn't suffer from the multi-thread reference counting problem. CPython uses immediate reference counting--ref counts are adjusted live every time a reference is created or deleted. Deferred reference counting works differently. Generally, it doesn't adjust reference counts for pointers in the stack/registers at all. Instead, it pauses all threads and scans the stack/registers with all threads paused to find references, just like a tracing collector. For references from the heap, a deferred reference counting algorithm will use a write barrier that queues the reference count in a local buffer. The locally-buffered increments/decrements will be resolved during the global pause. The difference between a DRC algorithm and a tracing algorithm is what needs to happen during the GC pause. A tracing collector has to trace all live objects (even a generational collector will trace all live objects eventually), in order to free any memory. A DRC collector just has to apply the deferred increments/decrements. Once those increments/decrements are applied, zero-count objects can be immediately deleted.