However, allocating memory in a shared heap, which means locking the heap everytime.
That's not how modern allocators work. Nim's is currently a notable exception with its single global lock, but '-d:useMalloc' fixes that. See also https://github.com/microsoft/mimalloc
I have done some benchmarks with some gcs. arc and orc seems to work fine with httpbeast. But when I benchmark prologue with many ref objects. It seems to slow down very much.
With refc, 50k qps
With arc, 7k qps
With orc, 18k qps
Any solutions?
Once we have Arc and multithreading fixed we can work on a fast threadsafe allocator. There is this for example that wraps Mimalloc https://github.com/Araq/araqsgc.
This is also something I noticed in Weave.
As I do here https://github.com/mratsim/weave/blob/e5a3701/weave/memory/allocs.nim#L47-L57 you can always import system/ansi_c and call c_malloc manually if your use-case allows it (i.e. you don't need the refcounting part).