Skip to content

Commit

Permalink
pcp: Disable incremental changes for layer operations by default
Browse files Browse the repository at this point in the history
Flip PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS to off
by default while we continue development. In the meantime,
this can be reenabled for testing/experimentation by setting
this environment variable to 1.

(Internal change: 2344776)
  • Loading branch information
sunyab authored and pixar-oss committed Oct 16, 2024
1 parent 1141751 commit 7929cf8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pxr/usd/pcp/changes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_ENV_SETTING(
PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS, true,
PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS, false,
"If enabled, pcp will compute a minimal amount of targeted change entries "
"for layer operations. This can result in a significant performance "
"improvement when muting/unmuting layer or adding/removing sublayers.");
Expand Down
12 changes: 10 additions & 2 deletions pxr/usd/pcp/testenv/testPcpChanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import unittest
from contextlib import contextmanager

INCREMENTAL_CHANGES = Tf.GetEnvSetting(
'PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS')

class TestPcpChanges(unittest.TestCase):
def test_EmptySublayerChanges(self):
subLayer1 = Sdf.Layer.CreateAnonymous()
Expand Down Expand Up @@ -153,8 +156,13 @@ def "B"

# With incremental changes these changes should only cause a resync
# of /A and /B.
self.assertEqual(cp.GetSignificantChanges(),
[Sdf.Path('/A'), Sdf.Path('/B')])
if INCREMENTAL_CHANGES:
self.assertEqual(cp.GetSignificantChanges(),
[Sdf.Path('/A'), Sdf.Path('/B')])
else:
self.assertEqual(cp.GetSignificantChanges(),
[Sdf.Path('/')])

self.assertEqual(cp.GetSpecChanges(), [])
self.assertEqual(cp.GetPrimChanges(), [])

Expand Down
30 changes: 25 additions & 5 deletions pxr/usd/pcp/testenv/testPcpExpressionComposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

import unittest

from pxr import Pcp, Sdf
from pxr import Pcp, Sdf, Tf

INCREMENTAL_CHANGES = Tf.GetEnvSetting(
'PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS')

def LoadPcpCache(rootLayer, sessionLayer = None):
l = Sdf.Layer.FindOrOpen(rootLayer)
Expand Down Expand Up @@ -208,7 +211,12 @@ def test_SublayerAuthoring(self):
# Since B.sdf is not empty, this should incur a significant resync.
with Pcp._TestChangeProcessor(pcpCache) as changes:
rootLayer.subLayerPaths.append('`"./B.sdf"`')
self.assertEqual(changes.GetSignificantChanges(), ['/Test'])

if INCREMENTAL_CHANGES:
self.assertEqual(changes.GetSignificantChanges(), ['/Test'])
else:
self.assertEqual(changes.GetSignificantChanges(), ['/'])

self.assertEqual(changes.GetSpecChanges(), [])

pi, err = pcpCache.ComputePrimIndex('/Test')
Expand All @@ -232,7 +240,12 @@ def test_SublayerAuthoring(self):
# Remove the sublayer we just added to reverse the changes.
with Pcp._TestChangeProcessor(pcpCache) as changes:
del rootLayer.subLayerPaths[-1]
self.assertEqual(changes.GetSignificantChanges(), ['/Test'])

if INCREMENTAL_CHANGES:
self.assertEqual(changes.GetSignificantChanges(), ['/Test'])
else:
self.assertEqual(changes.GetSignificantChanges(), ['/'])

self.assertEqual(changes.GetSpecChanges(), [])

pi, err = pcpCache.ComputePrimIndex('/Test')
Expand Down Expand Up @@ -319,7 +332,11 @@ def test_SublayerAuthoringAndVariableChange(self):
rootLayer.expressionVariables = {'X':'B'}
rootLayer.subLayerPaths.append('`"./${X}.sdf"`')

self.assertEqual(changes.GetSignificantChanges(), ['/BaseRef'])
if INCREMENTAL_CHANGES:
self.assertEqual(changes.GetSignificantChanges(), ['/BaseRef'])
else:
self.assertEqual(changes.GetSignificantChanges(), ['/'])

self.assertEqual(changes.GetSpecChanges(), [])

pi, err = pcpCache.ComputePrimIndex('/BaseRef')
Expand Down Expand Up @@ -1017,7 +1034,10 @@ def test_ExpressionVarChanges_SignificantLayerStackChanges(self):
rootLayer.expressionVariables = {'A':'C'}
rootLayer.subLayerPaths.append('sig_changes/sub.sdf')

self.assertEqual(changes.GetSignificantChanges(), ['/Dummy'])
if INCREMENTAL_CHANGES:
self.assertEqual(changes.GetSignificantChanges(), ['/Dummy'])
else:
self.assertEqual(changes.GetSignificantChanges(), ['/'])

self.AssertVariables(
pcpCache, '/Root1',
Expand Down

0 comments on commit 7929cf8

Please sign in to comment.