neoduan
neoduan

Reputation: 21

GO: runtime: program exceeds 10000-thread limit

when i using go, i got a error 'runtime: program exceeds 10000-thread limit'.

That is the information about goroutine. 'SCHED 229357ms: gomaxprocs=16 idleprocs=0 threads=8797 idlethreads=8374 runqueue=2131 gcwaiting=0 nmidlelocked=141 nmspinning=0 stopwait=0 sysmonwait=0'

we can see that has 8374 idlethreads, no reason to create any more thread by os.

why the program exceeds 10000-thread limit?

Upvotes: 2

Views: 4501

Answers (1)

Zan Lynx
Zan Lynx

Reputation: 54325

No way to provide a definitive answer without a lot of program code. And I doubt that you can provide a simplified example that will hit the problem. 10,000 threads is a lot of threads.

What I guess is that because Go creates a new thread for each goroutine's blocking operations, you have a lot of goroutines doing blocking calls.

I am not sure, but I think each goroutine keeps its own blocking call thread and they are not pooled. So having more than 10,000 goroutines that each make blocking calls may be the issue.

All guesses though.

EDIT:

Found a way to increase the 10,000 thread limit: https://golang.org/pkg/runtime/debug/#SetMaxThreads

debug.SetMaxThreads(20000)

Upvotes: 3

Related Questions