[PATCH][gdbsupport] Use task size in parallel_for_each

Tom Tromey tom@tromey.com
Fri Jul 22 19:08:25 GMT 2022


Pedro> My passerby comment is that I wonder whether we should consider
Pedro> switching to a work stealing implementation, so that threads that
Pedro> are done with their chunk would grab another chunk from the work
Pedro> pool.  I think this would spare us from having to worry about
Pedro> these distribution heuristics.

Tom> I also though about a dynamic solution, but decided to try the
Tom> simplest solution first.

Tom> Anyway, with a dynamic solution you still might want to decide how big
Tom> a chunck is, for which you could still need this type of heuristics.

I think the idea of the work-stealing approach is that each worker grabs
work as it can, and so no sizing is needed at all.  If one worker ends
up with a very large CU, it will simply end up working on fewer CUs.

In this situation, work stealing might make the overall implementation
simpler.  Perhaps the batching parameter patch (commit 82d734f7a) and
the vector of results patch (commit f4565e4c9) could be removed.

Then, rather than using parallel_for, the DWARF reader could send N jobs
to the thread pool, and each job would simply take the next available CU
by incrementing an atomic counter.  When the counter reached the number
of CUs, a job would stop.

Tom


More information about the Gdb-patches mailing list