[lld] r287042 - Use one task per iteration in parallel_for_loop.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 16 09:23:23 PST 2016


> I think I don't understand the point. This is a parallel_for_each. We know
> the exact number of tasks from the beginning, so we can compute how many
> tasks each core will take beforehand.
>
> Let's say we have 10,000 tasks and 10 cores. Then we know we should assign
> 1,000 tasks for each core at the beginning, so we can spawn 10 threads and
> give 1,000 tasks for each thread. Why doesn't this work?

OK, I can see the point that if the high level user creates too many
partitions, assigning them to threads in the most efficient way is a
good thing. The tradeoff is that if some partition turns out to be
easier, some threads will finish early and get idle.

So instead of 1024 this should probably be N (2?) times the size of
the thread pool, but starting with 1024 is fine assuming that you get
good performance with it.

LGTM, please just add comment saying that the thread pool has a fairly
high overhead so we try to reduce the number of tasks.

Cheers,
Rafael


More information about the llvm-commits mailing list