-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Improvements to subsystem query API #11333
Conversation
com.microsoft.mrtk.spatialmanipulation/Solvers/SolverHandler.cs
Outdated
Show resolved
Hide resolved
com.microsoft.mrtk.input/Visualizers/ControllerVisualizer/ControllerVisualizer.cs
Show resolved
Hide resolved
Profiling results here. Takeaways: the auto-scratchpad-list-system is equally performant to maintaining your own reusable list yourself. The Overall, the auto-scratch-list is 2x efficient over the naive call, and the direct helper property is an 86.7x speedup over the naive call. // Just checking .running property
// 0.00ms, GC = 0
bool test = true;
for (int i = 0; i < 10000; i++)
{
test &= hands.running;
}
// Direct helper property, cached
// 0.14ms, GC = 0
for (int i = 0; i < 10000; i++)
{
hands = XRSubsystemHelpers.HandsAggregator;
}
// Auto-scratch-list
// 6ms, GC = 0
for (int i = 0; i < 10000; i++)
{
hands = XRSubsystemHelpers.GetFirstRunningSubsystem<HandsAggregatorSubsystem>();
}
// Using Unity API directly, no reused list
// 8-12ms, GC = 20,000 (1.0 MB)
for (int i = 0; i < 10000; i++)
{
var list = new List<HandsAggregatorSubsystem>();
SubsystemManager.GetSubsystems(list);
if (list.Count > 0)
{
hands = list[0];
}
}
// Using Unity API directly, reusing list
// 6ish ms, GC = 0
for (int i = 0; i < 10000; i++)
{
SubsystemManager.GetSubsystems(reusableList);
if (reusableList.Count > 0)
{
hands = reusableList[0];
}
} |
@@ -110,7 +107,7 @@ public Vector3 PokePosition | |||
{ | |||
get | |||
{ | |||
if (HandSubsystem.TryGetJoint(TrackedHandJoint.IndexTip, | |||
if (XRSubsystemHelpers.HandsAggregator.TryGetJoint(TrackedHandJoint.IndexTip, |
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.
Missing a null check on the aggregator here and in GrabPosition
below
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.
Will do in another PR so that the change won't reset the approval :D
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.
Overall looks good, there are a couple of questions and it would be good to resolve the null check issues that @keveleigh pointed out.
com.microsoft.mrtk.input/Utilities/PoseSource/PolyfillHandRayPoseSource.cs
Show resolved
Hide resolved
* Cherrypicks from new_hand_menu * Removed confusing doccomment remark * Deprecating HandsUtils.Subsystem * Etc * Obsoleting some un-flaggy extension methods, fixing `ToXRNode` behavior * Refactors * More cleanup * Fixing doccomment * SolverHandler optimization * oops Co-authored-by: Kurtis <kurtie@microsoft.com>
…rosoft#11382) * Some missing nullchecks from the previous PR * Fixing deprecated usage + warnings
Overview
These are some significant improvements to the subsystem query API that were originally part of the
new_hand_menu
branch/PR. I still have a few last things to add to that before merging, but I wanted to get these improvements in ASAP.Changes
HandJointPose
to automatically cast it to aPose
Handedness
XRSubsystemUtilities
XRSubsystemHelpers
to internally reuse scratchpadList<T>
s, cached by generic type