Skip to content
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

Cache the QueryState used to drop swapchain TextureViews #11781

Merged

Conversation

james7132
Copy link
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
24 checks passed
@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