Improve performance of HID descriptor parsing and device matching#1579
Merged
Improve performance of HID descriptor parsing and device matching#1579
Conversation
e058d81 to
fc41fb3
Compare
jimon
approved these changes
Sep 2, 2022
Contributor
jimon
left a comment
There was a problem hiding this comment.
Tbh, not happy with this solution, we should just have a fast json parser period, or not use json for this to begin with.
But a good solution today is better than a great solution tomorrow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
During domain reloads, and during InputTestFixture test teardown, all device descriptions are parsed to see if the system can add any devices that it knows about but couldn't add previously. For HID devices, that means parsing the HID descriptor, which on later version of Unity, contains quite a lot of data. On machines with many HID devices attached, this parsing can get quite expensive.
Changes made
This PR replaces the parsing in the HID descriptor FromJson method with a custom predictive parser that depends on the descriptor being well formatted. If it fails, then processing falls back on the previous method. On 2022.1, this change resulted in full test runs going from 144 seconds down to 110. On previous Unity versions the test run improvement is only about two seconds as the HID descriptors have less data in them in those versions. Domain reload time is still improved though.
Checklist
Before review:
Changed,Fixed,Addedsections.([case %number%](https://issuetracker.unity3d.com/issues/...)).Area_CanDoX,Area_CanDoX_EvenIfYIsTheCase,Area_WhenIDoX_AndYHappens_ThisIsTheResult.During merge:
NEW: ___.FIX: ___.DOCS: ___.CHANGE: ___.RELEASE: 1.1.0-preview.3.