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

feature request: allow float for process count #6244

Open
jjb opened this issue Mar 26, 2024 · 2 comments
Open

feature request: allow float for process count #6244

jjb opened this issue Mar 26, 2024 · 2 comments

Comments

@jjb
Copy link
Contributor

jjb commented Mar 26, 2024

In my environment, the number of cpus on a container is available in an environment variable, CONTAINER_CPU_SHARE.

I would like to pass this to SIDEKIQ_COUNT

problem is, it can be a "half cpu", e.g. "2.5"

Maybe sidekiq could accept this and round up, with something like .to_f.ceil?

I would vote for rounding up, to take full advantage of the half cpu. This is on the side of slightly higher memory use, but my uninformed guess is most users who are passing in a value would be savvy enough to be okay with that.

@count = Integer(env["SIDEKIQ_COUNT"].to_f.ceil || Etc.nprocessors)
@mperham
Copy link
Collaborator

mperham commented Mar 26, 2024

-        @count = Integer(env["SIDEKIQ_COUNT"] || Etc.nprocessors)
+        @count = Float(env["SIDEKIQ_COUNT"] || Etc.nprocessors).round

This will round to the nearest integer: 2.4 -> 2 and 2.5 -> 3. wdyt?

@jjb
Copy link
Contributor Author

jjb commented Mar 26, 2024

i like it

pros:

  • simple reliable implementation
  • in my personal use case, it's always .5, so it works
  • my uninformed guess is most partial cpus are .5

cons:

  • i would want .4 to still be rounded up, maybe most others would as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants