#Best way to run parallel iterator on bevy;prelude;Query
15 messages · Page 1 of 1 (latest)
You're looking for par_for_each I think.
That's the bevy way to do that. Not as powerful as rayon, but it's integrated into the bevy task pool.
Mind you, it's certainly not required. You probably want to profile before switching to using parallel iterators, considering the overhead involved in task creation.
is there any overhead if i use impl fn on my structs over executing all logic and math from fn?
I don't think it would make a difference. The overhead of par_for_each is caused by the creation of the parallel tasks, not anything you're doing.
for what order of magnitude is viable to use parallel tasks or moving logic into compute shader?
Not sure. Personally it's been fairly inconsistent, so I always profile it.
Basically anytime I see a system that takes a long time (especially if it hurts my frame time noticeably) in my profiling I try a parallel version of it if It's feasable.
I know that Bevy can run rendering independent from logic, therefore is all bevy system (asset loader , ui, audio) are virtual threads? If so , does .add_system creates separate "thread"?
Far from an expert on the scheduler, but from what I understand, the scheduler has a set number of threads on which it dispatches systems based on their queries (so you can't get simultaneous mutable queries on the same components).
Someone like @lyric gazelle would probably know more I suspect.
Yes. Check the docs on Github on profiling using a flame graph!
Gracias