Can multithreading speed up memory allocation?

前端 未结 10 2350
感情败类
感情败类 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:14

    I believe the short answer to your question is : yes, probably. And as already pointed out by several people here there are ways to achieve this.

    Aside from your question and the answers already posted here, it would be good to start with your expectations on improvements, because that will pretty much tell which path to take. Maybe you need to be 100x faster. Also, do you see yourself doing speed improvements in the near future as well or is there a level which will be good enough? Not knowing your application or problem domain it's difficult to also advice you specifically. Are you for instance in a problem domain where speed continuously have to be improved?

    One good thing to start off with when doing performance improvements is to question if you need to do things the way you currently do it? In this case, can you pre-allocate objects? Is there a maximum number of X objects in the system? Could you re-use objects? All of this is better, because you don't necessarily need to do allocations on the critical path. E.g. if you can re-use objects, a custom allocator with pre-allocated objects would work well. Also, what OS are you on?

    If you don't have concrete expectations or a certain level of performance, just start experimenting with any of the advices here and you'll find out more.

    Good luck!

提交回复
热议问题