C: Lock-Free Memory Allocation Library
Asked Answered
C

3

9

Anyone have any good experience with a lock-free memory allocator for C/c++?

I have looked into boost, and libcds, but I am unsure about which library to use.

Background, I have been researching a "Lock-Free, Wait-Free, Non-Blocking, Dynamic Perfect Hashing, Expandable, Concurrent Hash Table" *Yes I know that sounds pretentious, but thats what it is called.

Anyways, I am getting ready to start multi-thread testing it, and I need to figure the best way to setup memory allocation, when new nodes are added. (and when I need to allocate arrays of pointers)

So does anyone have any good experience with lock free memory allocation?

Calcifuge answered 25/3, 2011 at 4:28 Comment(4)
Doesn't wait-free imply lock-free, lock-free imply non-blocking, and non-blocking imply concurrent? A bit redundant...Frumpy
I know, but my research professor likes to hit all the button words.Calcifuge
You missed NUMA-aware from the wish list. All basic allocator implementations wont fair well on NUMA hardware if you also want concurrency.Impostume
Voting to close as tool rec.Hussein
I
5

The pretty graphs show this implementation is good:

http://locklessinc.com/

It's open source GPL 3.0 since 14 Nov 2011 :)

Impostume answered 25/3, 2011 at 4:55 Comment(3)
They posted there performance benchmarking code, which is nice, because I wanted to look into a better timing tool then the standard time.hCalcifuge
@Feldman, you can see from the charts the alternatives: tcmalloc from Google nee jemalloc, and glibc's default allocator which is incredibly good these days.Impostume
And once again Hoard fails spectacularly. I've seen it recommended a number of times already yet every single benchmark I come upon place jemalloc and tcmalloc far ahead.Dangerous
A
2

There is also streamflow. I haven't used it myself; I just ran into it while reading some publications.

Askwith answered 25/3, 2011 at 6:51 Comment(0)
D
0

Why not try the allocator from tbb? not sure how 'lock-free' it is, though I doubt you'll find a true lock-free allocator*, at least one that works across threads/cores(like tcmalloc)

*I tried to actually build one a few months back, but making it lockless has some drawbacks, at least from my perspective. I wasn't too keen of TLS arena's like nedmalloc has. I ended up with a hybrid kinda allocator, which locks only when a chunk-bin is empty.

Decongestant answered 25/3, 2011 at 5:53 Comment(1)
There's a version of Hoard which is fully lock-free.Mokpo

© 2022 - 2024 — McMap. All rights reserved.