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?

4
  • 1
    Doesn't wait-free imply lock-free, lock-free imply non-blocking, and non-blocking imply concurrent? A bit redundant... Commented Mar 25, 2011 at 5:03
  • I know, but my research professor likes to hit all the button words. Commented Mar 25, 2011 at 5:14
  • 3
    You missed NUMA-aware from the wish list. All basic allocator implementations wont fair well on NUMA hardware if you also want concurrency. Commented Mar 25, 2011 at 6:10
  • Voting to close as tool rec. Commented Jun 25, 2015 at 14:29

3 Answers 3

5

The pretty graphs show this implementation is good:

http://locklessinc.com/

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

Sign up to request clarification or add additional context in comments.

3 Comments

They posted there performance benchmarking code, which is nice, because I wanted to look into a better timing tool then the standard time.h
@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.
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.
2

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

Comments

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.

1 Comment

There's a version of Hoard which is fully lock-free.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.