Skip to content

Task priorities #8

@chescock

Description

@chescock

What problem does this solve or what need does it fill?

Bevy currently has three isolated thread pools, "compute", "async compute", and "IO", and allocates 50%, 25%, and 25% of the CPU cores to each pool. In addition to that, it runs one main thread and one rendering thread.

Most of the time, the async compute and IO pools are idle, so Bevy is only using half of the cores (plus one or two, if the main or render threads are working). The simplest solution would be to consolidate them into a single pool, but then background work like asset loading can wind up using all the threads, leaving none for foreground work!

What solution would you like?

Support task priorities, so that we can run a single task pool but not have background work block progress on foreground work.

I don't know enough about realistic use cases to know how much complexity is necessary here! It may be enough to have two hard-coded priorities for "foreground" and "background" tasks, but we may need more.

It may be enough to let any worker take any task and just prefer foreground ones. But we may need to ensure that some workers cannot run background tasks, so that they are available immediately when foreground tasks are spawned. And may need to have some workers prefer background tasks so that background work can still make progress under heavy load.

Additional context

bevyengine/bevy#12090
bevyengine/bevy#4740

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions