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

many_components stress test improvements #16913

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

hymm
Copy link
Contributor

@hymm hymm commented Dec 20, 2024

Objective

  • I was getting familiar with the many_components example to test some recent pr's for executor changes and saw some things to improve.

Solution

  • Use insert_by_ids instead of insert_by_id. This reduces the number of archetype moves and improves startup times substantially.
  • Add a tracing span to base_system. I'm not sure why, but tracing spans weren't showing for this system. I think it's something to do with how pipe system works, but need to investigate more. The approach in this pr is a little better than the default span too, since it allows adding the number of entities queried to the span which is not possible with the default system span.
  • println the number of archetype component id's that are created. This is useful since part of the purpose of this stress test is to test how well the use of FixedBitSet scales in the executor.

Testing

  • Ran the example with cargo run --example many_components -F trace_tracy 1000000 and connected with tracy
  • Timed the time it took to spawn 1 million entities on main (240 s) vs this pr (15 s)

Showcase

image

Future Work

  • Currently systems are created with a random set of components and entities are created with a random set of components without any correlation between the randomness. This means that some systems won't match any entities and some entities could not match any systems. It might be better to spawn the entities from the pool of components that match the queries that the systems are using.

@hymm hymm added C-Examples An addition or correction to our examples A-ECS Entities, components, systems, and events C-Benchmarks Stress tests and benchmarks used to measure how fast things are D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed C-Examples An addition or correction to our examples labels Dec 20, 2024
}
}

println!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be info! so it can be configured with the logging framework?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure. I see some examples use info and some use println. This example was using println already, so I just kept it consistent.

examples/stress_tests/many_components.rs Outdated Show resolved Hide resolved
@hymm hymm added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Dec 24, 2024
@BenjaminBrienen BenjaminBrienen added the D-Unsafe Touches with unsafe code in some way label Dec 24, 2024
@BenjaminBrienen
Copy link
Contributor

Needing unsafe in the benchmarks makes me feel like we could improve the API.

@hymm
Copy link
Contributor Author

hymm commented Dec 24, 2024

Needing unsafe in the benchmarks makes me feel like we could improve the API.

it's because we're spawning things dynamically, for which I don't think we can avoid unsafe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Benchmarks Stress tests and benchmarks used to measure how fast things are D-Straightforward Simple bug fixes and API improvements, docs, test and examples D-Unsafe Touches with unsafe code in some way S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants