Can multithreading speed up memory allocation?

前端 未结 10 2366
感情败类
感情败类 2020-12-05 03:29

I\'m working with an 8 core processor, and am using Boost threads to run a large program. Logically, the program can be split into groups, where each group is run by a threa

10条回答
  •  猫巷女王i
    2020-12-05 03:57

    There are 2 scalable drop-in replacements for malloc that I know of:

    • Google's tcmalloc
    • Facebook's jemalloc (link to a performance study comparing to tcmalloc)

    I don't have any experience with Hoard (which performed poorly in the study), but Emery Berger lurks on this site and was astonished by the results. He said he would have a look and I surmise there might have been some specifics to either the test or implementation that "trapped" Hoard as the general feedback is usually good.

    One word of caution with jemalloc, it can waste a bit of space when you rapidly create then discard threads (as it creates a new pool for each thread you allocate from). If your threads are stable, there should not be any issue with this.

提交回复
热议问题