-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
High entity counts cause decreased rendering performance even when rendering nothing. #3953
Comments
Could we cache the reserved entities in some fashion? It seems strange that we're reserving this list from scratch each time. |
Possibly, I'm not sure. We might have to benchmark a few different approaches to see which one is best. 🤔 |
I've implemented a possible solution in my fork which reserves the number of entities used in the render world for the previous frame. This seems to fix performance with large numbers of non-rendering entities but does mean there's a single-frame slowdown if there are a lot of new rendering entities spawned. I think this is generally solvable by having a (configurable, maybe) minimum number of entities reserved. I tested this with the |
Excellent! @zyllian, are you comfortable making a PR for this? It will be easier to discuss and verify this further there. |
@alice-i-cecile Sure, here it is. |
So, thinking about this more: can we use the ExactSizeIterator tech in #4244 to get a quick and exact estimate? If so, we should merge that ASAP and fix it like that. |
Hello, what issues were there with Zylian's fix ? I see it has been closed, but there was no explanation given. |
|
# Objective - Improve #3953 ## Solution - The very specific circumstances under which the render world is reset meant that the flush_as_invalid function could be replaced with one that had a noop as its init method. - This removes a double-writing issue leading to greatly increased performance. Running the reproduction code in the linked issue, this change nearly doubles the framerate. Co-authored-by: Carter Anderson <[email protected]>
Closed by #5509? |
Yeah, let's close this for now. If further issues crop up, we can make a new issue. |
# Objective - Improve bevyengine#3953 ## Solution - The very specific circumstances under which the render world is reset meant that the flush_as_invalid function could be replaced with one that had a noop as its init method. - This removes a double-writing issue leading to greatly increased performance. Running the reproduction code in the linked issue, this change nearly doubles the framerate. Co-authored-by: Carter Anderson <[email protected]>
# Objective - Improve bevyengine#3953 ## Solution - The very specific circumstances under which the render world is reset meant that the flush_as_invalid function could be replaced with one that had a noop as its init method. - This removes a double-writing issue leading to greatly increased performance. Running the reproduction code in the linked issue, this change nearly doubles the framerate. Co-authored-by: Carter Anderson <[email protected]>
# Objective - Improve bevyengine#3953 ## Solution - The very specific circumstances under which the render world is reset meant that the flush_as_invalid function could be replaced with one that had a noop as its init method. - This removes a double-writing issue leading to greatly increased performance. Running the reproduction code in the linked issue, this change nearly doubles the framerate. Co-authored-by: Carter Anderson <[email protected]>
Bevy version
Main branch commit:
d8974e7c3d84189313268f475ceeff9393cedffa
Operating system & version
Windows 10 Vulkan and DX12 API.
What you did
The example code is small and easy to understand:
What you expected to happen
Creating large amounts of entities shouldn't decrease rendering performance unless they are actually drawing something to the screen.
What actually happened
Performance decreases rapidly with increased entity counts. On higher end machines this is less noticeable, but still becomes an issue.
Additional information
The decrease in performance can be traced to this:
bevy/crates/bevy_render/src/lib.rs
Lines 193 to 202 in 458cb7a
Reserving entity ID's for every entity seems to be costly when dealing with a large number of entities.
Possible solutions:
The text was updated successfully, but these errors were encountered: