Can multithreading speed up memory allocation?

前端 未结 10 2340
感情败类
感情败类 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条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 04:03

    1. The best what you can try to reach ~8 memory allocation in parallel (since you have 8 physical cores), not 10000 as you wrote

    2. standard malloc uses mutex and standard STL allocator does the same. Therefore it will not speed up automatically when you introduce threading. Nevertheless, you can use another malloc library (google for e.g. "ptmalloc") which does not use global locking. if you allocate using STL (e.g. allocate strings, vectors) you have to write your own allocator.

    Rather interesting article: http://developers.sun.com/solaris/articles/multiproc/multiproc.html

提交回复
热议问题