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

Guard against unnecessary array detaches in attribute creation #2816

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

nvmkuruc
Copy link
Collaborator

@nvmkuruc nvmkuruc commented Nov 15, 2023

Description of Change(s)

Consider the following snippet--

# testDetach.py
from pxr import Usd
from pxr import UsdGeom

stage = Usd.Stage.CreateInMemory()
points = UsdGeom.Points.Define(stage, "/points")
points.CreatePointsAttr()

Running

VT_LOG_STACK_ON_ARRAY_DETACH_COPY=1 python3 testDetach.py

produces 16 VtArray detaches due to non-const access of override property names in schemaRegistry.cpp. While not verified, we suspect that there are two detaches per schema in its type hierarchy (Points has 7 ancestors plus itself => 8 total schema types).

This guards against detaches by both making the VtTokenArrays const. Rerunning testDetach.py with this change and VT_LOG_STACK_ON_ARRAY_DETACH_COPY=1 shows zero detaches.

Fixes Issue(s)

  • I have verified that all unit tests pass with the proposed changes
  • I have submitted a signed Contributor License Agreement

@nvmkuruc
Copy link
Collaborator Author

Thanks to @andrewkaufman for discovering this issue.

@jesschimein
Copy link
Contributor

Filed as internal issue #USD-8959

@spiffmon
Copy link
Member

Wow, nice find, @andrewkaufman !

@pixar-oss pixar-oss merged commit 4ae72c7 into PixarAnimationStudios:dev Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants