Page MenuHome

Add support for the TBB allocator on windows.

Authored by LazyDodo (LazyDodo) on Fri, Nov 8, 11:07 PM.



The heap on windows is single threaded causing it to lag behind linux in performance in allocation heavy multithreaded scenarios, BVH building is a prime example.

Results of CPU Render on an aws c5d.18xlarge instance

Total Render TimeScene PrepTotal ImprovementPrep Improvement
sceneMSVC HeapTBB_AllocatorMSVC HeapTBB_AllocatorSeconds%Seconds%

notable changes:

  • Required a version bump for TBB for the hooking to work on recent windows versions.
  • Static versions of tbbmalloc/tbbmalloc_proxy do not seem to work (static tbb is frowned upon anyway, but that's a worry for a future diff) so the dynamic versions were used.
  • Windows only at this point, given the linux allocator is multithreaded by default I'm not expecting wonders there.

for testing with the allocator enabled/disabled you can set the environment variable TBB_MALLOC_DISABLE_REPLACEMENT=1 to disable the allocator.

for easy testing drop these files into the tbb/lib folder

Diff Detail

rB Blender

Event Timeline

LazyDodo (LazyDodo) edited the summary of this revision. (Show Details)
  • Fix: unmodified tbb header doesn't work for C code.

I had this fixed locally, but it's better to do this without modifications to tbb

That's a great find!

I guess this can not be done as a static library (similar to how we link against jemalloc)? Not as if it's a big deal, just the amount of dll's is quite high..

But even then, i think it totally worth using TBB's allocator.

This revision is now accepted and ready to land.Tue, Nov 12, 9:53 AM

Static version gave issues: they depend on getting notifications of new/terminated threads though dllmain, which will work for a shared lib, but won't work so great if you statically link that lib into your exe.

I have some work underway to move all dll's out of the main blender folder and to their own subfolders D6132 is a start for the CRT, the others can be moved as well, but i have no patch for that yet.

It's currently disabled, before landing should we enable this for just windows?

If there are precompiled libraries in SVN we should enable it on Windows, yes.

This revision was automatically updated to reflect the committed changes.