Task scheduler: Optimize parallel loop over lists
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 20 Nov 2018 11:17:03 +0000 (12:17 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 20 Nov 2018 13:58:17 +0000 (14:58 +0100)
commit01e8e7dc6d9dd3710e0e3872b2d70196ac654d14
tree0f4e3045967e3ff897558e7658e0cc33474fe671
parent9bc2570e2ac7e3fc5e6095af300ef863d3ba4ca6
Task scheduler: Optimize parallel loop over lists

The goal is to address performance regression when going from
few threads to 10s of threads. On a systems with more than 32
CPU threads the benefit of threaded loop was actually harmful.

There are following tweaks now:

- The chunk size is adaptive for the number of threads, which
  minimizes scheduling overhead.

- The number of tasks is adaptive to the list size and chunk
  size.

Here comes performance comparison on the production shot:

 Number of threads        DEG time before        DEG time after
       44                     0.09                   0.02
       32                     0.055                  0.025
       16                     0.025                  0.025
       8                      0.035                  0.033
source/blender/blenlib/intern/task.c