PXR_WORK_THREAD_LIMIT not respected by WorkParallelForN on non-main thread

Hi - I was a bit surprised to find out today that if you set the PXR_WORK_THREAD_LIMIT env var to 1, that you will still get parallel execution (using the tbb default number of threads) if you call WorkParallelForN from any thread other than the main thread (for example, from HdRenderThread).

Is this expected behavior? If not, I can file an issue with simple reproduction…

We’ve seen this as well. The problem gets fixed indirectly by upgrading to a newer TBB because the current (deprecated) init function OpenUSD is using no longer exists. There’s a PR that happens to include the change: cmake adapting oneTBB: migrate tbb to oneTBB by wangcan26 · Pull Request #2825 · PixarAnimationStudios/OpenUSD · GitHub. You can pick the changes in pxr/base/work/threadLimits.cpp. The key is to use tbb::global_control instead of the old tbb::task_scheduler_init.

Gotcha - well, good to know I wasn’t the only one seeing it. Seeing as how it seems that oneTBB support is “imminent”, I guess this should be solved soon. Thanks!