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

SetMaxPoolSize not heeded #10584

brentp opened this issue Feb 6, 2019 · 2 comments


None yet
2 participants
Copy link

commented Feb 6, 2019

when using threadpool + spawn after setMaxPoolSize, it always uses all available CPUs. here is the code to reproduce. Even though it uses setMaxPoolSize(1) it will use all available CPUs:

import threadpool
import math

proc work(k:int): float =
  for i in 0..<10000000:
    result += sin(i.float)
  result -= k.float

proc main() =

  var responses = newSeq[FlowVarBase](1000)

  for i in 0..<responses.len:
    responses[i] = spawn work(i)

  for i, fv in responses:


This comment has been minimized.

Copy link

commented Feb 6, 2019

Good news, this is easy to fix :)

  • setMaxPoolSize (and setMinPoolSize) do not perform any check in order to maintain the min < max invariant.
  • Nothing ever tears down the running worker threads, for some weird reason the shutdown flag in slave is reset and the pool size decreased but nothing at all is done about the thread. Adding a return makes the usage 100% on a single cpu only here (after setting setMinPoolSize(1)).

This comment has been minimized.

Copy link
Contributor Author

commented Feb 6, 2019

thanks for the fix!

narimiran added a commit that referenced this issue Feb 20, 2019

fixes #10584 [backport]
(cherry picked from commit 65f3e39)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.