Skip to content

SpherePointer query optimization#10324

Merged
RogPodge merged 7 commits into
microsoft:prerelease/2.8.0from
jonathoncobb:jonathoncobb/query-caching
May 16, 2022
Merged

SpherePointer query optimization#10324
RogPodge merged 7 commits into
microsoft:prerelease/2.8.0from
jonathoncobb:jonathoncobb/query-caching

Conversation

@jonathoncobb

Copy link
Copy Markdown
Member

Overview

The SpherePointer performs multiple queries per frame at times and with every collider returned it performs a costly GetComponent call on the collider to retrieve the NearInteractionGrabbable component.

Changes

This PR optimizes that logic by adding a LRU cache to the SpherePointer to cache the retrieved NearInteractionGrabbable component. The cache holds a user defined number of entries, and the cache is purged when the SpherePointer is destroyed.

Editor mode unit tests are implemented for the new utilities class LRUCache.

Comment thread Assets/MRTK/SDK/Features/Utilities/UnitTests/LRUCacheUnitTests.cs Outdated
Comment thread Assets/MRTK/SDK/Features/Utilities/LRUCache.cs Outdated
Comment thread Assets/MRTK/SDK/Features/Utilities/LRUCache.cs Outdated
Comment thread Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs Outdated
Comment thread Assets/MRTK/SDK/Features/UX/Scripts/Pointers/SpherePointer.cs Outdated
Comment thread Assets/MRTK/SDK/Features/Utilities/LRUCache.cs
@jonathoncobb jonathoncobb force-pushed the jonathoncobb/query-caching branch from 8c66491 to c61c68d Compare November 17, 2021 23:18
The SpherePointer performs multiple queries per frame at times and with every collider returned it performs a costly GetComponent call on the collider to retrieve the NearInteractionGrabbable component.

This PR optimizes that logic by adding a LRU cache to the SpherePointer to cache the retrieved NearInteractionGrabbable component. The cache holds a user defined number of entries, and the cache is purged when the SpherePointer is destroyed.

Editor mode unit tests are implemented for the new utilities class LRUCache.
@jonathoncobb jonathoncobb force-pushed the jonathoncobb/query-caching branch from c61c68d to 31e4bb1 Compare November 17, 2021 23:53
@RogPodge RogPodge changed the base branch from main to prerelease/2.8.0 May 13, 2022 18:25
@RogPodge

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@RogPodge

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@RogPodge

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

Comment thread Assets/MRTK/SDK/Features/Utilities/LRUCache.cs Outdated
Comment thread Assets/MRTK/SDK/Features/Utilities/LRUCache.cs Outdated
Comment thread Assets/MRTK/Tests/PlayModeTests/Core/Utilities/LRUCacheUnitTests.cs Outdated
@keveleigh

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@RogPodge RogPodge merged commit 40894a6 into microsoft:prerelease/2.8.0 May 16, 2022
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