Skip to content

Adjust the Global Executor thread count #593

@deankarn

Description

@deankarn

I was wondering if there is any ability, or plans, to support setting the maximum number of threads for the global executor?

I see the num_cpus is used here which is great 99% of the time, my use case, however, is for docker.

num_cpus can/will show more CPU's than is allocated for the container to use. I was hoping to be able to directly control this for situations like this.

Thanks you in advance for any information you can provide :)

Activity

yoshuawuyts

yoshuawuyts commented on Dec 12, 2019

@yoshuawuyts
Contributor

Hey there! Thanks for asking. We definitely want to provide such controls, but it's a question of how we should go about this. One option that's been mentioned is passing it as a global variable. But we haven't really talked about this much, primarily also because setting max threads can be risky (deadlocks!), and setting boundaries in terms of cpu cycles and memory usage tends to be a better option in practice.

deankarn

deankarn commented on Dec 12, 2019

@deankarn
Author

@yoshuawuyts I completely agree that in practice most of the time this is a sane default, I just hope that the option to tweak at this low level is not abstracted away so far that it is not tunable and glad it's being thought about 😃

ozgrakkurt

ozgrakkurt commented on Mar 22, 2023

@ozgrakkurt

Hey @deankarn,

this issue seems to be solved.

Tracking how async-std handles thread count limits:

So it seems to use this by default.
And it seems to be controllable by ASYNC_STD_THREAD_COUNT env var.

Apparently this doesnt cover spawn_blocking calls. Those seem like they can be controlled by BLOCKING_MAX_THREADS env var. I found it from async-rs/async-global-executor#4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api designOpen design questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yoshuawuyts@deankarn@ozgrakkurt

        Issue actions

          Adjust the Global Executor thread count · Issue #593 · async-rs/async-std