Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USDLayerWriter performance improvements #6254

Merged

Conversation

johnhaddon
Copy link
Member

This builds on #6232, improving USDLayerWriter performance by removing the identical parts of the scene before writing them to USD for diffing. I'm seeing a 50x speedup on a benchmark which changes shader assignment on a single location in the ALab scene, and close to a 5x speedup changing shader assignment on every location in the same scene.

Only the last two commits are unique to this PR - the others are borrowed from #6232.

@johnhaddon johnhaddon self-assigned this Feb 3, 2025
Copy link
Contributor

@danieldresser-ie danieldresser-ie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a couple of style notes, but nothing that should prevent this from being immediately merged. Definitely seems like a big win.

if( objectsMatch )
{
objectsMatch = baseScene->objectPlug()->hash() == layerScene->objectPlug()->hash();
canPrune = canPrune && objectsMatch;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an aesthetics thing, but I think I would find this a bit clearer if the first two assignments to canPrune were replaced with canPrune = canPrune && attributesMatch && objectsMatch in the canPrune branch below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't liking the aesthetics much here, so I thought I'd like this suggestion. But it means either introducing another if( canPrune ) conditional after doing that assignment, or potentially evaluating the transform unnecessarily if the assignment was false. So I've left as-is for now.

}
}

ScenePlug::ScenePath prefix;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the name prefix a bit odd here ... it didn't take too much investigation to conclude that everything here is correct: the name of the current location is the prefix that needs to be added to any downstream paths in order to make them relative to this path. But just seeing path.back() assigned to a var named "prefix" looks weird.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't like the name either, but I wasn't sure what else to call it. name didn't seem quite right since sometimes it is empty. In bf97464 I've renamed it to localPath and added a short comment - is that an improvement at all?

taskGroupContext


);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've already talked about whether this could fit into a parallelGatherLocations style idiom, and you've concluded that not worrying about that is the best way to get this rolled out, which is totally reasonable. Might be worth a comment though - do you have any expectation about whether it's likely to improve performance to avoid the overhead of doing nested parallel_reduce? Or would it just be an aesthetic thing to make it fit in with other traversal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment in f99b188. I don't think there would be any performance difference in USDLayerWriter either way - a SceneAlgo version would still use nested parallel_reduce, just as parallelProcessLocations() uses nested parallel_for(). But there could be benefits to using this approach to building PathMatchers elsewhere.

@johnhaddon johnhaddon force-pushed the usdLayerWriterPerformance branch from 1e7b222 to f99b188 Compare February 4, 2025 11:31
@johnhaddon
Copy link
Member Author

Thanks Daniel - I've replied to your latest comments, and also added a fixup for a problem I found in last-minute testing : 62d6ef5.

@danieldresser-ie
Copy link
Contributor

LGTM

@johnhaddon johnhaddon force-pushed the usdLayerWriterPerformance branch from 63bb9d0 to e4535e3 Compare February 5, 2025 09:13
@johnhaddon johnhaddon merged commit 6922a9f into GafferHQ:1.5_maintenance Feb 5, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants