You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under Linux a process can be restricted to the number of threads and processes it can launch at any one time. When hitting the process limit, pthread_create will start failing with EAGAIN which causes the go runtime to abort (see bugs #4056 and #14835).
In #4056 it is mentioned that a user should be managing the number of threads (see Comment 33 #4056 (comment) from @dvyukov)
Users must limit number of threads in sys/cgo calls.
However, different systems can vary widely in the number of threads that you are allowed to create. It is very common on server systems to have a thread limit of 10k, while on desktop and embedded systems it could be as little as 512. Thus the user need to know about the number of threads/processes that an operating system will allow.
Linux provides the ability to read this information using the getrlimit syscall, calling with RLIMIT_NPROC (see http://man7.org/linux/man-pages/man2/getrlimit.2.html). The go runtime already provides access to getrlimit in the syscall.Getrlimit (see https://golang.org/pkg/syscall/#Getrlimit) but this module doesn't currently have the RLIMIT_NPROC resource constant (maybe because it isn't POSIX?).
From the getrlimit man page;
RLIMIT_MEMLOCK and RLIMIT_NPROC derive from BSD and are not specified in POSIX.1-2001; they are present on the BSDs and Linux, but on few other implementations.
ianlancetaylor
changed the title
runtime: syscall.Getrlimit should support RLIMIT_NPROC (number of process limits)
syscall: Getrlimit should support RLIMIT_NPROC (number of process limits)
Mar 18, 2016
minux
changed the title
syscall: Getrlimit should support RLIMIT_NPROC (number of process limits)
x/sys/unix: Getrlimit should support RLIMIT_NPROC (number of process limits)
Mar 18, 2016
the syscall package is frozen, please add the missing
RLIMIT_* constants to x/sys/unix instead.
Note that it's very hard for the user to manage runtime
OS threads. Not only the user must limit concurrent cgo
calls, the user also must limit concurrent blocking syscalls
(file open/read/write, etc.)
Even it's possible for the user to carefully limit the
concurrency of sysclal/cgo in his/here own packages,
external packages might still pose a problem.
Under Linux a process can be restricted to the number of threads and processes it can launch at any one time. When hitting the process limit,
pthread_create
will start failing with EAGAIN which causes the go runtime to abort (see bugs #4056 and #14835).In #4056 it is mentioned that a user should be managing the number of threads (see Comment 33 #4056 (comment) from @dvyukov)
However, different systems can vary widely in the number of threads that you are allowed to create. It is very common on server systems to have a thread limit of 10k, while on desktop and embedded systems it could be as little as 512. Thus the user need to know about the number of threads/processes that an operating system will allow.
Linux provides the ability to read this information using the getrlimit syscall, calling with RLIMIT_NPROC (see http://man7.org/linux/man-pages/man2/getrlimit.2.html). The go runtime already provides access to
getrlimit
in the syscall.Getrlimit (see https://golang.org/pkg/syscall/#Getrlimit) but this module doesn't currently have the RLIMIT_NPROC resource constant (maybe because it isn't POSIX?).From the getrlimit man page;
I believe this can probably be very easily fixed by changing the regex in mkerrors.sh like shown in this patch here -> https://go-review.googlesource.com/#/c/20751/1/src/syscall/mkerrors.sh
The text was updated successfully, but these errors were encountered: