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

[Merged by Bors] - Add stress test for many ui elements #5253

Closed
wants to merge 2 commits into from

Conversation

nicopap
Copy link
Contributor

@nicopap nicopap commented Jul 8, 2022

Objective

Bevy need a way to benchmark UI rendering code,
this PR adds a stress test that spawns a lot of buttons.

Solution

  • Add the many_buttons stress test.

Changelog

  • Add the many_buttons stress test.

@nicopap nicopap mentioned this pull request Jul 8, 2022
@alice-i-cecile alice-i-cecile added C-Performance A change motivated by improving speed, memory usage or compile times A-UI Graphical user interfaces, styles, layouts, and widgets A-Diagnostics Logging, crash handling, error reporting and performance analysis labels Jul 8, 2022
@mockersf
Copy link
Member

mockersf commented Jul 8, 2022

This is not testing much of the UI, just spawning buttons:

  • Should it add more hierarchies? This impact layout a lot
  • Should layout change each frame? Without that it's pretty much static once spawned
  • Should the mouse position change automatically during the test? Otherwise the interaction part is not stress tested, unless the user randomly moves the mouse, which is not really reproducible twice in the same way

@nicopap nicopap marked this pull request as draft July 9, 2022 05:09
@nicopap
Copy link
Contributor Author

nicopap commented Jul 9, 2022

@mockersf

I want to keep this test focused. The original version of this test in ui-navigation did indeed only exist to test the focus system (well, my own). However, the ui rendering code is just too slow for even the slowest and most naive mouse picking algorithm to contribute in any meaningful way to the global run time of the app. You are indeed right. There is no hierarchy or change to layout, yet the test is still staggeringly slow I get 2FPS in release mode. Given the layout is static, this should be smooth as butter. Why is it so slow? Well, now we have a test to help us answer that question!

Here are the most prominent tracing spans in tracy:

  • system{name="bevy_ui::flex::flex_node_system"}
  • system{name="bevy_ui::render::prepare_uinodes"}
  • node{name="bevy_ui::render::render_pass::UiPassNode"}

This stress test was already helpful, it helped me test if #5252 made the base case slower.

@nicopap nicopap marked this pull request as ready for review July 9, 2022 05:33
@mockersf
Copy link
Member

mockersf commented Jul 9, 2022

Ha I didn't expect just buttons to be that slow...
But then, it's displaying 62500 buttons. for reference, many_sprites is around 10000, many_cubes around 11000

for reference:

example fps on my laptop
many_buttons 5
many_buttons (just 10000 buttons) 41
many_cubes 90
many_sprites 73

So even for similar number of elements, UI is slower

Copy link
Member

@mockersf mockersf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the FrameTimeDiagnosticsPlugin and LogDiagnosticsPlugin plugins like in other stress tests?
In this example I don't think it's needed to display the ui element count as there isn't culling

@mockersf
Copy link
Member

mockersf commented Jul 9, 2022

Most of the improvements that were made to the sprite systems were not made for the ui, so it should be "easy" to improve. This example will help for that.

After that, we could add complexity to test other things

@nicopap nicopap marked this pull request as draft July 11, 2022 11:14
@nicopap nicopap marked this pull request as ready for review July 11, 2022 12:37
@nicopap nicopap requested a review from mockersf July 11, 2022 12:37
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on board. We should add a deeply nested layout stress test later, but that can wait.

@mockersf mockersf 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 Jul 21, 2022
@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jul 21, 2022
# Objective

Bevy need a way to benchmark UI rendering code,
this PR adds a stress test that spawns a lot of buttons.

## Solution

- Add the `many_buttons` stress test.

---

## Changelog

- Add the `many_buttons` stress test.
@bors bors bot changed the title Add stress test for many ui elements [Merged by Bors] - Add stress test for many ui elements Jul 21, 2022
@bors bors bot closed this Jul 21, 2022
inodentry pushed a commit to IyesGames/bevy that referenced this pull request Aug 8, 2022
# Objective

Bevy need a way to benchmark UI rendering code,
this PR adds a stress test that spawns a lot of buttons.

## Solution

- Add the `many_buttons` stress test.

---

## Changelog

- Add the `many_buttons` stress test.
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

Bevy need a way to benchmark UI rendering code,
this PR adds a stress test that spawns a lot of buttons.

## Solution

- Add the `many_buttons` stress test.

---

## Changelog

- Add the `many_buttons` stress test.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

Bevy need a way to benchmark UI rendering code,
this PR adds a stress test that spawns a lot of buttons.

## Solution

- Add the `many_buttons` stress test.

---

## Changelog

- Add the `many_buttons` stress test.
@nicopap nicopap deleted the many-buttons branch September 5, 2023 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Diagnostics Logging, crash handling, error reporting and performance analysis A-UI Graphical user interfaces, styles, layouts, and widgets 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