-
Notifications
You must be signed in to change notification settings - Fork 328
FIX: JsonParser / ParseStringValue now creates unescaped strings #1986
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
Conversation
…ings to improve comparison performance when activating devices.
…e improvement (ISX-1450)
…n TryMatchDisconnectedDevice o Native deviceDescriptor / capabilities field is escaped Json string o Managed description.capabilities string is non-escaped Json string o Use temporary escaped Json string for quicker comparison
o Move MakeEscapedJsonString functionality to its own function o Devices_RemovingAndReaddingDevice_DoesNotAllocateMemory now expects a single (string) GC allocation per call to ReportNewInputDevice o Fix for PrimitiveValue ToBoolean for double type (logic was inverted)
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.
LGTM, looks like a good improvement @AlexTyrer
return !Mathf.Approximately(m_FloatValue, default); | ||
case TypeCode.Double: | ||
return NumberHelpers.Approximately(m_DoubleValue, default); | ||
return !NumberHelpers.Approximately(m_DoubleValue, default); |
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.
Bonus bug fix?
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.
Yes, I spotted a bug we didn't even know we had!
|
||
### Changed | ||
- Use `ProfilerMarker` instead of `Profiler.BeginSample` and `Profiler.EndSample` when appropriate to enable recording of profiling data. | ||
- Improved performance of disconnected device activation (ISX-1450) |
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.
I think this could live under ### Fixed since it's not really a changed behavior, right?
Description
Comparing escaped and non-escaped strings is very slow - this happens when devices are deactivated/reactivated such as when the Quest2 headset and controllers enter and awake from sleep mode.
The high cost comes from having to compare each string character-by-character (skipping '' escapes) each time entering the C# runtime to perform System.Globalization.ToUpperInvariant.
Changes made
This change to TryMatchDisconnectedDevice() means that any parsed strings that contain escape characters are converted to non-escaped strings for much quicker comparison.
This saves approximately 0.5ms / frame when an Oculus headset or controller is reactivated.
Testing
Local testing with the Quest2 headset and controllers using Superluminal to capture the cost of device awakening.
Risk
We allocate a temporary string where before we did not.
Checklist
Before review:
Changed
,Fixed
,Added
sections.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.After merge: