Jacques Lucke
b99c1abc3a
BLI: speedup memory bandwidth bound tasks by reducing threading
...
This improves performance by **reducing** the amounts of threads used for tasks
which require a high memory bandwidth.
This works because the underlying hardware has a certain maximum memory
bandwidth. If that is used up by a few threads already, any additional threads
wanting to use a lot of memory will just cause more contention which actually
slows things down. By reducing the number of threads that can perform certain
tasks, the remaining threads are also not locked up doing work that they can't
do efficiently. It's best if there is enough scheduled work so that these tasks
can do more compute intensive tasks instead.
To use this new functionality, one has to put the parallel code in question into
a `threading::memory_bandwidth_bound_task(...)` block. Additionally, one also
has to provide a (very) rough approximation for how many bytes are accessed. If
the number is low, the number of threads shouldn't be reduced because it's
likely that all touched memory can be in L3 cache which generally has a much
higher bandwidth than main memory.
The exact number of threads that are allowed to do bandwidth bound tasks at the
same time is generally highly context and hardware dependent. It's also not
really possible to measure reliably because it depends on so many static and
dynamic factors. The thread count is now hardcoded to 8. It seems that this many
threads are easily capable of maxing out the bandwidth capacity.
With this technique I can measure surprisingly good performance improvements:
* Generating a 3000x3000 grid: 133ms -> 103ms.
* Generating a mesh line with 100'000'000 vertices: 212ms -> 189ms.
* Realize mesh instances resulting in ~27'000'000 vertices: 460ms -> 305ms.
In all of these cases, only 8 instead of 24 threads are used. The remaining
threads are idle in these cases, but they could do other work if available.
Pull Request: https://projects.blender.org/blender/blender/pulls/118939
2024-03-19 18:23:56 +01:00
..
2024-03-19 18:23:56 +01:00
2024-03-17 09:52:32 +01:00
2023-08-16 00:20:26 +10:00
2024-01-06 01:47:39 +01:00
2024-02-06 14:52:15 +01:00
2023-05-31 16:19:06 +02:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-03-19 10:39:05 +01:00
2023-08-16 00:20:26 +10:00
2024-01-31 14:16:22 +01:00
2023-08-16 00:20:26 +10:00
2024-01-06 01:47:39 +01:00
2023-12-20 20:58:38 -05:00
2024-02-19 02:09:55 -05:00
2023-08-16 00:20:26 +10:00
2024-01-06 01:47:39 +01:00
2023-08-16 09:51:37 +02:00
2024-01-06 01:47:39 +01:00
2024-01-06 01:47:39 +01:00
2024-02-22 12:57:10 +01:00
2024-03-05 11:29:04 -05:00
2024-01-03 13:38:14 +01:00
2023-05-31 16:19:06 +02:00
2024-03-05 14:32:48 +01:00
2024-03-05 14:32:48 +01:00
2024-01-19 12:08:48 -05:00
2023-08-17 23:17:30 +10:00
2023-08-16 00:20:26 +10:00
2024-01-19 20:29:38 +01:00
2023-11-20 09:39:13 +01:00
2024-03-06 16:14:34 +01:00
2023-10-30 21:40:35 +01:00
2024-01-03 13:38:14 +01:00
2023-11-20 09:39:13 +01:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2024-03-19 13:45:04 +01:00
2023-08-16 09:51:37 +02:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-09 16:21:31 -05:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-03 13:38:14 +01:00
2023-05-31 16:19:06 +02:00
2023-05-31 16:19:06 +02:00
2023-05-31 16:19:06 +02:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-06 09:06:20 -05:00
2023-08-16 00:20:26 +10:00
2023-05-31 16:19:06 +02:00
2023-11-30 22:35:00 +01:00
2023-08-16 00:20:26 +10:00
2023-10-10 15:36:15 +02:00
2023-05-31 16:19:06 +02:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-03 13:38:14 +01:00
2023-08-16 00:20:26 +10:00
2024-02-02 19:55:06 +01:00
2023-12-27 12:34:49 -05:00
2024-02-02 19:55:06 +01:00
2024-02-19 15:59:59 +01:00
2024-02-02 19:55:06 +01:00
2024-01-06 01:47:39 +01:00
2023-08-16 00:20:26 +10:00
2024-01-26 11:45:56 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-12-20 15:32:52 +01:00
2023-08-16 00:20:26 +10:00
2024-02-29 17:14:58 +01:00
2024-03-17 09:52:32 +01:00
2024-02-04 11:55:45 +01:00
2024-03-17 09:52:32 +01:00
2024-03-17 09:52:32 +01:00
2023-08-16 09:51:37 +02:00
2023-08-16 00:20:26 +10:00
2023-05-31 16:19:06 +02:00
2023-11-30 14:15:11 +11:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-03-05 11:29:04 -05:00
2023-08-16 00:20:26 +10:00
2024-02-05 15:20:34 +01:00
2024-02-28 22:22:21 +01:00
2024-03-17 09:52:32 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-07-26 16:12:55 +02:00
2023-05-31 16:19:06 +02:00
2023-08-16 00:20:26 +10:00
2023-10-30 21:40:35 +01:00
2024-01-03 13:38:14 +01:00
2023-11-21 13:38:43 +01:00
2024-01-09 18:05:12 +01:00
2023-11-20 09:39:13 +01:00
2023-11-11 21:09:54 +01:00
2023-08-16 00:20:26 +10:00
2024-01-25 11:45:24 +01:00
2024-01-09 18:05:12 +01:00
2024-02-23 12:41:22 -05:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-10 14:51:40 +03:00
2024-01-03 13:38:14 +01:00
2023-08-16 00:20:26 +10:00
2023-11-20 09:39:13 +01:00
2023-08-16 00:20:26 +10:00
2024-02-13 20:35:08 -03:00
2023-05-31 16:19:06 +02:00
2024-02-19 15:59:59 +01:00
2024-03-03 16:26:04 +01:00
2024-02-19 15:59:59 +01:00
2024-01-09 18:05:12 +01:00
2023-08-16 00:20:26 +10:00
2024-01-09 18:05:12 +01:00
2023-11-20 09:39:13 +01:00
2023-11-11 22:15:02 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-09-04 14:49:28 +02:00
2024-01-09 18:05:12 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-09-03 16:43:45 +02:00
2024-01-31 21:12:16 -05:00
2023-10-30 21:40:35 +01:00
2023-12-07 12:45:27 +11:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-03 13:38:14 +01:00
2024-01-19 12:08:48 -05:00
2023-12-30 20:16:03 -05:00
2024-01-09 18:05:12 +01:00
2023-10-30 21:40:35 +01:00
2023-11-21 13:38:43 +01:00
2023-05-31 16:19:06 +02:00
2023-11-18 09:40:44 +01:00
2024-02-22 12:57:10 +01:00
2024-02-19 15:59:59 +01:00
2023-11-27 16:10:43 +01:00
2024-01-03 13:38:14 +01:00
2023-06-13 14:36:32 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-06 01:47:39 +01:00
2023-05-31 16:19:06 +02:00
2023-07-31 13:02:30 +10:00
2024-01-19 11:58:02 +01:00
2024-02-19 15:59:59 +01:00
2023-08-16 00:20:26 +10:00
2023-07-07 15:42:07 +10:00
2023-08-16 00:20:26 +10:00
2023-05-31 16:19:06 +02:00
2024-03-13 14:52:57 -04:00
2024-01-22 13:47:13 +01:00
2023-08-16 00:20:26 +10:00
2023-10-07 23:14:04 +02:00
2024-02-19 15:54:08 +01:00
2024-03-06 16:14:34 +01:00
2023-05-31 16:19:06 +02:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-06 01:47:39 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2023-09-20 12:11:30 +10:00
2024-02-20 17:52:14 +01:00
2024-02-19 15:59:59 +01:00
2023-10-30 21:40:35 +01:00
2023-12-13 12:14:29 +11:00
2024-01-04 15:07:48 -05:00
2023-11-17 00:11:40 +01:00
2023-11-20 09:39:13 +01:00
2023-11-20 09:39:13 +01:00
2023-05-31 16:19:06 +02:00
2024-02-19 15:59:59 +01:00
2023-12-05 23:01:12 +01:00
2024-03-19 18:23:56 +01:00
2024-03-04 11:42:02 +11:00
2023-08-16 00:20:26 +10:00
2024-02-19 15:59:59 +01:00
2024-02-19 15:59:59 +01:00
2023-08-16 00:20:26 +10:00
2023-11-13 10:42:29 +01:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2024-01-03 13:38:14 +01:00
2023-12-06 16:05:14 +01:00
2023-08-16 00:20:26 +10:00
2024-01-31 21:12:16 -05:00
2023-08-16 00:20:26 +10:00
2024-02-20 15:20:11 +01:00
2024-03-08 17:15:08 +11:00
2023-08-16 00:20:26 +10:00
2023-08-16 00:20:26 +10:00
2023-10-07 23:14:04 +02:00
2024-01-06 01:47:39 +01:00
2024-02-04 11:55:45 +01:00
2024-02-19 15:59:59 +01:00
2023-08-16 00:20:26 +10:00
2023-11-28 13:30:18 -05:00
2023-11-01 01:44:51 +01:00
2024-01-03 13:38:14 +01:00
2024-03-17 09:52:32 +01:00