Page MenuHomePhabricator

Avoid some memory allocations in the ThreadPool

Authored by espindola on Apr 27 2018, 12:49 PM.



I was surprised to see std::function related allocations showing up it a profile of lld. In the case of lld the allocations are tiny and don't really impact performance.

I am not sure if we should be trying to improve this code as it probably needs a full rewrite for better performance, but I was curious how hard it would be to remove some of the allocations.

Note that this only updated one of the executors so far.

Diff Detail

Event Timeline

espindola created this revision.Apr 27 2018, 12:49 PM
dblaikie accepted this revision.Apr 27 2018, 6:25 PM

If no one else is using the 'add' API - could simplify it to take a function pointer, if the goal is to avoid situations that might cause allocation overhead?

This revision is now accepted and ready to land.Apr 27 2018, 6:25 PM
dblaikie added inline comments.Apr 27 2018, 6:26 PM

This should probably take Latch by reference. I know lld has a bit of a different coding convention there - but it's not usually done that way in LLVM (well, it's perhaps a bit all over the shop, to be fair).