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 transform hierarchy stress test #4170

Closed
wants to merge 4 commits into from

Conversation

CptPotato
Copy link
Contributor

@CptPotato CptPotato commented Mar 10, 2022

Objective

There recently was a discussion on Discord about a possible test case for stress-testing transform hierarchies.

Solution

Create a test case for stress testing transform propagation.

Edit: I have scrapped my previous example and built something more functional and less focused on visuals.

There are three test setups:

  • TestCase::Tree recursively creates a tree with a specified depth and branch width

  • TestCase::NonUniformTree is the same as Tree but omits nodes in a way that makes the tree "lean" towards one side, like this:

    image

  • TestCase::Humanoids creates one or more separate hierarchies based on the structure of common humanoid rigs

    • this can both insert active and inactive instances of the human rig

It's possible to parameterize which parts of the hierarchy get updated (transform change) and which remain unchanged. This is based on @james7132 suggestion:
There's a probability to decide which entities should remain static. On top of that these changes can be limited to a certain range in the hierarchy (min_depth..max_depth).

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Mar 10, 2022
@superdump superdump added A-Rendering Drawing game state to the screen A-Transform Translations, rotations and scales C-Examples An addition or correction to our examples and removed S-Needs-Triage This issue needs to be labelled labels Mar 10, 2022
@superdump
Copy link
Contributor

Personally I would like to have a home for these kinds of test examples that are useful for development.

@alice-i-cecile alice-i-cecile added the C-Performance A change motivated by improving speed, memory usage or compile times label Mar 10, 2022
@alice-i-cecile
Copy link
Member

alice-i-cecile commented Mar 10, 2022

Personally I would like to have a home for these kinds of test examples that are useful for development.

Seconding this: @CptPotato can you start a "stress_tests" folder in "examples" for this to live in? We can move the related benchmarky-examples into there in a follow-up PR.

@james7132 @superdump ping me when you think this is ready; I can merge this in for you to help unblock more experiments.

@james7132
Copy link
Member

james7132 commented Mar 10, 2022

A few requests from me:

  • The ability to set the proportion of how many are mutated every frame. This can be used to tell how effective our hierarchy dirtying detection/propagation is. Randomly choosing whether we include or exclude the Rotate component is sufficient. Tentatively, this should probably could also have a control on the minimum and maximum depths this occurs at.
  • Non uniform distributions of hierarchy depths as an optional parameter. We'll probably find a few cases where there are huge numbers of uniform depth transforms, then a few deep cases (thinking active character models among a scene of otherwise normal scene geometry that might get de-parented/marked static in final builds).

This should let us test this at varying conditions typically expected out of a game scene (mostly static? mostly moving? how deep are the mutations?)

@CptPotato
Copy link
Contributor Author

Good points @james7132. I think I'll also change the code to be more "functional" rather than trying to make it look nice.

I have some ideas for how to address these things. Tough, it might take me a couple of days to get to it.

create example folder for stress tests
@CptPotato CptPotato changed the title Hierarchy fractal example Add transform hierarchy stress test Mar 13, 2022
@CptPotato
Copy link
Contributor Author

CptPotato commented Mar 13, 2022

Alright, I created the stress_test sub folder and moved the example there.

I have mostly rewritten the example, ditching the focus on visuals and taking some feedback into account, there's some more info in the PR description. The branch name doesn't really fit anymore but I guess that's okay?

I'm still not too sure about the configuration part. I tried making it as versatile as reasonably possible but it seems a little bloated to me.

Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

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

One typo, and please fix the CI, but otherwise amazing. This is exactly the kind of tests we needed.

examples/stress_tests/transform_hierarchy.rs Outdated Show resolved Hide resolved
@CptPotato
Copy link
Contributor Author

Good to hear this is on the right track.

Should we include a number of preset configurations for easier and more consistent testing?
Like:

cargo r --example transform_hierarchy -- 1
cargo r --example transform_hierarchy -- 2
...

@superdump
Copy link
Contributor

If we do that, it would be good if they had memorable and descriptive names. 🙂 Like max-depth (a single long chain of hierarchy for worst case), max-width (like the many_cubes — sphere case of 160k root entities with transforms), varied-depth (perhaps specifying a depth range and the branches have paths that are various lengths within that depth range to try to simulate something reasonably realistic)?

examples/README.md Outdated Show resolved Hide resolved
examples/README.md Show resolved Hide resolved
+ ci fixes
@CptPotato
Copy link
Contributor Author

CptPotato commented Mar 20, 2022

Sorry for the delay. I added a few test cases that can be run like this:

cargo r --example transform_hierarchy -- <name>

These are the setups I came up with:

Configuration Description
large_tree A fairly wide and deep tree.
wide_tree A shallow but very wide tree.
deep_tree A deep but not very wide tree.
chain A chain. 2500 levels deep.
update_leaves Same as large_tree, but only leaves are updated.
update_shallow Same as large_tree, but only the first few levels are updated.
humanoids_active 4000 active humanoid rigs.
humanoids_inactive 4000 humanoid rigs. Only 10 are active.
humanoids_mixed 2000 inactive and 2000 active humanoid rigs.
drawing A rendering-heavy configuration. Meshes and materials are shared.
drawing_unique Same as drawing, but all meshes and materials are unique.

I shot for ~250k to 350k entities for each of those, I think this should provide a heavy enough load.
The main exception is the chain test case. I couldn't make this one much more extreme without running into stack overflows.


Edit: I'm thinking about removing the last two configurations (the drawing ones) and removing the related code from the example, unless somebody needs those. Rendering performance seem a little outside of what the stress test is meant for, and it might be a better fit for a separate rendering/batching stress test.

@alice-i-cecile
Copy link
Member

Edit: I'm thinking about removing the last two configurations (the drawing ones) and removing the related code from the example, unless somebody needs those. Rendering performance seem a little outside of what the stress test is meant for, and it might be a better fit for a separate rendering/batching stress test.

I agree with this.

@CptPotato CptPotato marked this pull request as ready for review March 21, 2022 14:26
@CptPotato
Copy link
Contributor Author

Alright, the drawing related code is gone, I also switched to MinimalPlugins while I was at it.

I'm fairly happy with this as it is. Let me know if I should add/change anything!

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.

Looks good to me! I'm quite happy with this code, and it should be very useful for development.

Once I have another approval I'm happy to merge this in, and then I'd like to reshuffle the other stress tests into this folder.

@alice-i-cecile
Copy link
Member

bors r+

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

There recently was a discussion on Discord about a possible test case for stress-testing transform hierarchies.

## Solution

Create a test case for stress testing transform propagation.

*Edit:* I have scrapped my previous example and built something more functional and less focused on visuals.

There are three test setups:

- `TestCase::Tree` recursively creates a tree with a specified depth and branch width
- `TestCase::NonUniformTree` is the same as `Tree` but omits nodes in a way that makes the tree "lean" towards one side, like this:
  <details>
  <summary></summary>

  ![image](https://user-images.githubusercontent.com/3957610/158069737-2ddf4e4a-7d5c-4ee5-8566-424a54a06723.png)
  </details>
- `TestCase::Humanoids` creates one or more separate hierarchies based on the structure of common humanoid rigs
  - this can both insert `active` and `inactive` instances of the human rig

It's possible to parameterize which parts of the hierarchy get updated (transform change) and which remain unchanged. This is based on @james7132 suggestion:
There's a probability to decide which entities should remain static. On top of that these changes can be limited to a certain range in the hierarchy (min_depth..max_depth).
@bors bors bot changed the title Add transform hierarchy stress test [Merged by Bors] - Add transform hierarchy stress test Mar 21, 2022
@bors bors bot closed this Mar 21, 2022
aevyrie pushed a commit to aevyrie/bevy that referenced this pull request Jun 7, 2022
## Objective

There recently was a discussion on Discord about a possible test case for stress-testing transform hierarchies.

## Solution

Create a test case for stress testing transform propagation.

*Edit:* I have scrapped my previous example and built something more functional and less focused on visuals.

There are three test setups:

- `TestCase::Tree` recursively creates a tree with a specified depth and branch width
- `TestCase::NonUniformTree` is the same as `Tree` but omits nodes in a way that makes the tree "lean" towards one side, like this:
  <details>
  <summary></summary>

  ![image](https://user-images.githubusercontent.com/3957610/158069737-2ddf4e4a-7d5c-4ee5-8566-424a54a06723.png)
  </details>
- `TestCase::Humanoids` creates one or more separate hierarchies based on the structure of common humanoid rigs
  - this can both insert `active` and `inactive` instances of the human rig

It's possible to parameterize which parts of the hierarchy get updated (transform change) and which remain unchanged. This is based on @james7132 suggestion:
There's a probability to decide which entities should remain static. On top of that these changes can be limited to a certain range in the hierarchy (min_depth..max_depth).
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
## Objective

There recently was a discussion on Discord about a possible test case for stress-testing transform hierarchies.

## Solution

Create a test case for stress testing transform propagation.

*Edit:* I have scrapped my previous example and built something more functional and less focused on visuals.

There are three test setups:

- `TestCase::Tree` recursively creates a tree with a specified depth and branch width
- `TestCase::NonUniformTree` is the same as `Tree` but omits nodes in a way that makes the tree "lean" towards one side, like this:
  <details>
  <summary></summary>

  ![image](https://user-images.githubusercontent.com/3957610/158069737-2ddf4e4a-7d5c-4ee5-8566-424a54a06723.png)
  </details>
- `TestCase::Humanoids` creates one or more separate hierarchies based on the structure of common humanoid rigs
  - this can both insert `active` and `inactive` instances of the human rig

It's possible to parameterize which parts of the hierarchy get updated (transform change) and which remain unchanged. This is based on @james7132 suggestion:
There's a probability to decide which entities should remain static. On top of that these changes can be limited to a certain range in the hierarchy (min_depth..max_depth).
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 A-Transform Translations, rotations and scales C-Examples An addition or correction to our examples C-Performance A change motivated by improving speed, memory usage or compile times
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants