Is it possible to increase the thread limit per process?

That's pretty much it -- I can increase memory, file descriptor, etc., but can I increase the number of threads?

(I've got a case where, in an error condition, my threads block [still trying to figure out why] and new ones are still being generated, until I hit a limit of 512 threads.)

Answered by DTS Engineer in 795102022
can I increase the number of threads?

No [1].

That limit is very high, and if you’re hitting it then the correct path forward is to investigate why you’re hitting it, not to try to raise it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Well, it is, as always, complex, but the 512 limit is likely to be the maximum number of work queue threads, and that’s not something you can adjust [2].

[2] Well, it is, as always, complex, because you can adjust this using the kern.wq_max_threads sysctl, but that’s a system-wide setting, not a per-process setting.

Accepted Answer
can I increase the number of threads?

No [1].

That limit is very high, and if you’re hitting it then the correct path forward is to investigate why you’re hitting it, not to try to raise it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Well, it is, as always, complex, but the 512 limit is likely to be the maximum number of work queue threads, and that’s not something you can adjust [2].

[2] Well, it is, as always, complex, because you can adjust this using the kern.wq_max_threads sysctl, but that’s a system-wide setting, not a per-process setting.

Alas.

I did figure out my design problem, which was creating all of the threads, however, the user-space proxy has a separate thread per network connection.

Ok, that is a dispatch thread limit; that's different from OS threads. That makes sense.

Is it possible to increase the thread limit per process?
 
 
Q