This change addresses regressions that stem from a subtle difference in the way boost...
authormatthewcpp <matthewcpp@users.noreply.github.com>
Fri, 15 Dec 2023 00:35:08 +0000 (16:35 -0800)
committerpixar-oss <pixar-oss@users.noreply.github.com>
Fri, 15 Dec 2023 19:17:17 +0000 (11:17 -0800)
The effect of this difference in behavior can be observed in the _ComposeSubtree method. With std::optioanl's implementation the `if(_dispatcher)` check returns false and these will not be enqueued to the dispatcher. The result was a significant speed regression due to lack of parallelism.

This fix adds and explict call to WorkDispatcher::Wait() before setting _dispatcher to std::nullopt. This ensures that all tasks are enqueued and will be processed in parallel.

(Internal change: 2308941)

pxr/usd/usd/stage.cpp

index 26c88821bfd350b991d1ba353d1d588b9bac84ea..6b06547b5f3e33f51616022bf58cc97e2cc06cd2 100644 (file)
@@ -3264,10 +3264,12 @@ UsdStage::_ComposeSubtreesInParallel(
                 }
             }
             catch (...) {
+                _dispatcher->Wait();
                 _dispatcher = std::nullopt;
                 throw;
             }
             
+            _dispatcher->Wait();
             _dispatcher = std::nullopt;
         });
 }
@@ -3421,6 +3423,7 @@ UsdStage::_DestroyPrimsInParallel(const vector<SdfPath>& paths)
                 });
             }
         }
+        _dispatcher->Wait();
         _dispatcher = std::nullopt;
     });
 }