Nim --gc:refc cycle collector pause latency under concurrent request threads
0 reputation · 16 Jul 2024, 18:26 UTC
Nim's garbage collector backend choice influences pause behavior during concurrent request handling, though pause-bound guarantees are not formally specified across versions. The --gc:refc flag shifts reclamation to reference counting while retaining a periodic cycle collector whose latency depends on heap size, allocation rate, and thread contention. Default GC settings and OS thread scheduling vary between Nim releases, producing latency variance that single-threaded async benchmarks do not reveal.
When multiple mutator threads process simultaneous requests, allocation-triggered collections or cycle-reclamation cycles suspend all sharing-heap threads, producing tail-latency spikes that are unpredictable without explicit pause-bound contracts. The language provides --gc:markAndSweep, --gc:refc, --gc:boehm, and --gc:go options, yet the exact conditions triggering pauses, their maximum duration, and thread-safety assurances remain implementation-defined rather than stable API contracts.
What factors determine the cycle collector's pause frequency under sustained concurrent allocation in Nim? How does the pause-bound behavior differ between --gc:markAndSweep and --gc:refc when request concurrency exceeds the single-event-loop capacity? Why are deterministic latency guarantees absent from the documented --gc configuration options across supported Nim versions?