Page MenuHome

Add support for the TBB allocator on windows.
ClosedPublic

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

Details

Summary

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%
barbershop_interior_cpu245.03235.2734.9229.69.763.985.3215.23
bmw27_cpu54.854.231.341.220.571.040.128.96
classroom_cpu159.34156.32.631.993.041.910.6424.33
fishy_cat_cpu94.0789.159.537.274.925.232.2623.71
koro_cpu168.95167.037.985.961.921.142.0225.31
pavillon_barcelona_cpu167.67165.161.591.482.511.500.116.92
sponza_cycles_testing81.7580.862.282.260.891.090.020.88
victor471.51437.3894.2271.3734.137.2422.8524.25

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

Repository
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.