Go to file
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
.gitea Docs: Replace most wiki links with links to new developer docs 2024-01-18 16:49:38 +01:00
.github Docs: Replace most wiki links with links to new developer docs 2024-01-18 16:49:38 +01:00
build_files Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
doc Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
extern Extern libs: Remove info to update THIRD-PARTY-LICENSES 2024-03-19 17:06:31 +01:00
intern Fix: Cycles area light ignores some valid samples in volume segment 2024-03-19 14:48:43 +01:00
lib Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
locale I18N: Updated UI translations from git/weblate (efe372a7b46cf). 2024-03-12 15:09:03 +09:00
release Merge branch 'blender-v4.1-release' 2024-03-19 16:47:14 +01:00
scripts Merge branch 'blender-v4.1-release' 2024-03-19 11:59:26 -04:00
source BLI: speedup memory bandwidth bound tasks by reducing threading 2024-03-19 18:23:56 +01:00
tests Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
tools check_licenses: exclude ./lib/ from source code checks 2024-03-19 14:10:27 +11:00
.clang-format Clang-Format: Ensure single new line at the end of files 2024-02-22 14:42:10 +01:00
.clang-tidy Clang-tidy: Ignore variable name length and .c/.cc include warnings 2022-05-06 15:26:54 +02:00
.editorconfig editorconfig: add HTML entry 2023-12-08 13:28:13 +11:00
.git-blame-ignore-revs Cleanup: add commit to .git-blame-ignore-revs 2023-05-03 20:31:11 +10:00
.gitignore Switch SVN to Git submodules using Git-LFS 2024-02-22 13:50:55 +01:00
.gitmodules Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
AUTHORS Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
CMakeLists.txt Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
COPYING
GNUmakefile Revert changes from main commits that were merged into blender-v4.1-release 2024-03-18 15:04:12 +01:00
make.bat Switch SVN to Git submodules using Git-LFS 2024-02-22 13:50:55 +01:00
pyproject.toml Black: skip string normalisation 2024-01-22 10:09:33 +01:00
README.md Docs: Replace most wiki links with links to new developer docs 2024-01-18 16:49:38 +01:00

Blender

Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline-modeling, rigging, animation, simulation, rendering, compositing, motion tracking and video editing.

Blender screenshot

Project Pages

Development

License

Blender as a whole is licensed under the GNU General Public License, Version 3. Individual files may have a different, but compatible license.

See blender.org/about/license for details.