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

Using ComputeTaskPool for a par_for_each query only uses half of available logical cores #1907

Open
MJohnson459 opened this issue Apr 13, 2021 · 1 comment · May be fixed by #12090
Open
Labels
A-Core Common functionality for all bevy apps C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times

Comments

@MJohnson459
Copy link
Contributor

Bevy version

0.5

Operating system & version

Linux

What you did

I have a CPU heavy task and running it as part of a query par_for_each loop in a ComputeTaskPool and only half of my cores are being utilised. I originally used an AsyncTaskPool but this has even fewer threads assigned.

use bevy::tasks::ComputeTaskPool;
pub fn how_many_threads(pool: Res<ComputeTaskPool>, query: Query<(&DummyComponent)>) {
    info!("TaskPool threads: {}", pool.thread_num());
    info!("Available cores: {}", num_cpus::get());

    query.par_for_each_mut(&pool, 1, |_dummy| {
        // Will only run on
    });
}

TaskPool threads: 6
Available cores: 12

I know why this happens but it was unexpected:

impl Default for DefaultTaskPoolOptions {

What you expected to happen

When not using the IoTaskPool or AsyncComputeTaskPool I would expect the ComputeTaskPool to use all logical cores. Likewise I would expect the other pools to expand to optimally use the CPU available.

Alternatively, documentation should be updated to make clear what the current behaviour is and steps to create a new task pool.

What actually happened

Only half of the available core were used.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Core Common functionality for all bevy apps C-Performance A change motivated by improving speed, memory usage or compile times labels Apr 13, 2021
@james7132
Copy link
Member

This seems like it would be resolved by #4740. Probably helps that #4791 was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Core Common functionality for all bevy apps C-Bug An unexpected or incorrect behavior C-Performance A change motivated by improving speed, memory usage or compile times
Projects
None yet
3 participants