简体   繁体   中英

Running Out of Threads on Debian

I have a program that creates a specified amount of active threads on my debian machine. When I try to create anything over 100 I get an error saying "Error in creating thread" when it reaches the OS limitation and machine doesn't accept any incoming connections and when executing commands I get "-bash: fork: Cannot allocate memory". Looking at the top command I see tasks are getting maxed out at 32564 and only 20% of my RAM is being utilized. I tried editing ulimit -a & -n to 500000 and -s to 81920 but still doesn't do anything. Any help is greatly appreciated/.

From my own experience, when using threads a good rule of thumb for increased performance for CPU bound processes is to use an equal number of threads as cores, except in the case of a hyper-threaded system in which case one should use twice as many cores. The other rule of thumb that can be concluded is for I/O bound processes. This rule is to quadruple the number threads per cores, except for the case of a hyper-threaded system, then one can quadruple the number of threads per core. So you probably shouldn't be making 100's of threads anyway. Just do "enough".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM