-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Improve runtime of GetScenePrimPaths from O(N log(N)) to O(N) #1822
Improve runtime of GetScenePrimPaths from O(N log(N)) to O(N) #1822
Conversation
@tcauchois Here is the follow up to #1744. |
cc @marktucker. Thanks Markus, we'll take a look! |
Filed as internal issue #USD-7304 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mtavenrath, left a few review notes for you to take a look at. Thanks!
// instance index. | ||
return primPaths.size() != instanceIndices.size(); | ||
|
||
result[instanceIndices[instanceIdxShifted]] = adapter->_GetPrimPathFromInstancerChain(instanceChain); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: Our coding conventions use a max column width of 80 characters. Could you please line-wrap this (and other lines below) to conform to that limit?
for (size_t i = 0; i < remappedIndices.size(); i++) | ||
result.push_back(primPathsFn.primPaths[remappedIndices[i]]); | ||
if (!instanceIndices.empty()) { | ||
int minIdx = INT_MAX; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use either INT_MAX or std::numeric_limits::max() consistently instead of using both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to std::numeric_limits::max()
// Indices in the map set to the maximum int value are not being referenced. | ||
std::vector<int> requestedIndicesMap(maxIdx - minIdx + 1, std::numeric_limits<int>::max()); | ||
|
||
// set bits for all requested indices to truefor (size_t i = 0; i < instanceIndices.size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a mangled comment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next line slipped in the comment. fixed
if (instanceIdxShifted < 0) | ||
return true; | ||
|
||
// stop enumeration once the max index has been reached | ||
if (size_t(instanceIdxShifted) >= instanceIndices.size()) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: Our code conventions require enclosing braces even around conditionals with one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
243a24d
to
04dd60c
Compare
… costly std::map/std::set data structures.
04dd60c
to
ef3a99e
Compare
Description of Change(s)
Replace the std::set & std::map in GetScenePrimPaths by a std::vector for better memory utilization & linear time access.
Fixes Issue(s)
Improved performance of GetScenePrimPaths
I have submitted a signed Contributor License Agreement