Skip to content

proposal: runtime: disallow changing GOMAXPROCS #20303

@valyala

Description

@valyala

The runtime.GOMAXPROCS function allows updating the number of p at any time during the program execution. This could be useful before go1.5 when GOMAXPROCS was set to 1 by default and when goroutine scheduler wasn't very good.

Now the goroutine scheduler is great and GOMAXPROCS equals to the number of available CPU cores by default. So there are no major reasons to change it during program execution. Additionally, GOMAXPROCS may be overridden via environment variable at program start if required:

GOMAXPROCS=1 ./path/to/program

The ability to change GOMAXPROCS in runtime complicates the code in runtime and sync packages. @dvyukov should agree with this :)

The documentation to runtime.GOMAXPROCS explicitly says:

This call will go away when the scheduler improves.

Maybe it's time to make runtime.GOMAXPROCS no-op, i.e. just return the GOMAXPROCS value set at program start?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions