Skip to content

Cache the QueryState used to drop swapchain TextureViews#11781

Merged
alice-i-cecile merged 3 commits intobevyengine:mainfrom
james7132:cache-query-state-present-frames
Feb 9, 2024
Merged

Cache the QueryState used to drop swapchain TextureViews#11781
alice-i-cecile merged 3 commits intobevyengine:mainfrom
james7132:cache-query-state-present-frames

Conversation

@james7132
Copy link
Copy Markdown
Member

Objective

While profiling around to validate the results of #9172, I noticed that present_frames can take a significant amount of time. Digging into the cause, it seems like we're creating a new QueryState from scratch every frame. This involves scanning the entire World's metadata instead of just updating its view of the world.

Solution

Use a SystemState argument to cache the QueryState to avoid this construction cost.

Performance

Against many_foxes, this seems to cut the time spent in present_frames by nearly almost 2x. Yellow is this PR, red is main.

image

@james7132 james7132 added A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times labels Feb 8, 2024
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 9, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 9, 2024
Merged via the queue into bevyengine:main with commit f26b438 Feb 9, 2024
@james7132 james7132 deleted the cache-query-state-present-frames branch March 10, 2024 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants