The slowdown associated with the vector :: push_back and posting a new one in a multi-threaded application

I have a multi-threaded application in which my use of threads is very poor (in a ball park 1% -4% per thread, with fewer threads than processors). In the debugger, it seems to spend a lot of time in vector :: push_back, in particular on a new placement that happens during push_back. I tried using reserve to avoid vector expansion and copying everything, but that is not a problem. Commenting the vector :: push_backs results in significant use of threads.

This problem occurs with uint64_t vectors, so it is not the result of complex object construction. I tried using both a standard dispenser and my own dispenser, and both run the same way. Vectors are used by the same stream that allocated them.

+3
source share
3 answers

If you do not need these initialized values ​​at 0, consider writing a vector class that is not initialized. I found this to measure performance gains in some scenarios.

Side note. When your profiler claims that you spend most of your time doing primitive operations with 64-bit integers, you know that the rest of your code is decently optimized.

+3
source

, - , , push_back , 0 - at operator[]. .

+1

All Articles