-
Notifications
You must be signed in to change notification settings - Fork 301
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
Support spawn setting of 0 to mean number of cpus #2711
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey! i like the idea of this feature. the one issue i have is that i think that the behaviour of --spawn 0
would be a bit surprising having not read the help text - ie if you read it in a config file or similar.
how would you feel about implementing this as a separate flag called something like --spawn-per-cpu <some number>
, and have the agent spawn ceil(cfg.SpawnPerCPU * runtime.NumCPU())
children, and make this flag mutually exclusive with --spawn
?
Yep that works for me! |
…r of cpus When setting up the agent config some setups may not have the number of CPUs available but want to spawn one worker per CPU, --spawn-per-cpu 1 will do this. We can even do more than 1-per-cpu if this host is meant for light weight/io bound tasks for example. Signed-off-by: Manuel Mendez <[email protected]>
@moskyb I've updated the PR. I'm not sure I follow your use case for In the meantime here's the output of some manual testing:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making that change, @mmlb! The reference to ceil
was an idea that we could make the flag a float, allowing for --spawn-per-cpu 0.5
etc, rounding up to ensure the result is an int. We'll get this merged in though, and we can potentially make that float change in the future!
🥳 |
Description
When setting up the agent config some setups may not have the number of CPUs available but want to spawn one worker per CPU. In this case we can interpret 0 to mean all CPUs.
Other options I considered were treating spawn as a string and doing some simple math but this seems saner (not to mention simpler).
Context
I'd like to run 1 agent worker per process running under NixOS, declaratively so can't use
nproc
other means.Testing
go test ./...
). Buildkite employees may check this if the pipeline has run automatically.go fmt ./...
)