Question about SystemParam
#18774
-
Consider this as a noob question! Let say I have this struct. #[derive(SystemParam)]
struct Config<'w, 's> {
query_a: Query<'w, 's, ........>, // about 10 - 15 components
query_b: Query<'w, 's, ........>,
query_c: Query<'w, 's, ........>,
.
.
query_n: Query<'w, 's, ........>,
mut my_resource: ResMut<'w, ConfigData>
}
impl<'w, 's> Config<'w, 's> {
fn work_with_query_a(&mut self) {
// do some iterations and mutations
}
} From bevy documentation: My question: Please advise, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
As you have linked from the Query documentation, creating the Query should not have the performance cost associated with running it. |
Beta Was this translation helpful? Give feedback.
As you have linked from the Query documentation, creating the Query should not have the performance cost associated with running it.
However, there is still a way that these queries may hurt performance just by their declaration: when using the multi-thread executor (default), these queries may prevent other systems querying some of the same
Components
from running in parallel with your system using thisSystemParam
(depending on the declared Components mutability). So if you rely highly on systems parallelism, this might something to be aware of.