Closed
Description
It comes up repeatedly that programs with large numbers of goroutines spawn far more operating system threads than they can reasonably use, because the Go runtime is trying not to find itself in a situation where every thread is blocked in the operating system. Unfortunately this means that if something in the OS gets backed up Go just keeps making more threads as more goroutines get stuck there. For example if DNS queries (done via cgo) get stuck for a little while, then a program with 5000 HTTP-fetching goroutines will end up with 5000 threads attempting DNS queries. The usual "solution" is for callers of cgo code to limit by hand the number of goroutines entering that code. I wonder if the runtime should expose a setting giving the maximum number of OS threads to use. 256 or 512 could be a reasonable default - those seem quite high and all the trouble I have seen has been with far more threads. It would probably be like // MaxOSThreads sets the maximum number of OS threads that will // be used to run the current Go program and returns the previous setting. // If n < 1, it does not change the current setting. The default is 256. func MaxThreads(n int) int
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
bradfitz commentedon Sep 10, 2012
Comment 1:
rsc commentedon Sep 10, 2012
Comment 2:
ianlancetaylor commentedon Sep 10, 2012
Comment 3:
dvyukov commentedon Sep 10, 2012
Comment 4:
rsc commentedon Sep 10, 2012
Comment 5:
dvyukov commentedon Sep 10, 2012
Comment 6:
ianlancetaylor commentedon Sep 10, 2012
Comment 7:
rsc commentedon Sep 10, 2012
Comment 8:
dvyukov commentedon Sep 10, 2012
Comment 9:
rsc commentedon Sep 11, 2012
Comment 10:
rsc commentedon Sep 12, 2012
Comment 12:
Labels changed: added go1.1.
bradfitz commentedon Nov 8, 2012
Comment 13:
rsc commentedon Dec 10, 2012
Comment 14:
Labels changed: added size-m.
rsc commentedon Dec 10, 2012
Comment 15:
Labels changed: added suggested.
gopherbot commentedon Feb 4, 2013
Comment 16 by rickarnoldjr:
34 remaining items