Identify mapping between goroutines and OS threads in stack trace

60 views
Skip to first unread message

varun...@gmail.com

unread,
Jan 12, 2021, 10:46:47 AM1/12/21
to golang-nuts
Hi, I would like to know how to identify mapping between an OS thread and go-routine from the stack trace i.e. which go-routine is scheduled for execution on a OS thread.

Background: My application spawns very large number of go-routines (upto 2M) for heavy data processing. In some cases, I am seeing the thread exhaustion limit panic

runtime: program exceeds 10000-thread limit
fatal error: thread exhaustion

I have the complete stack trace from the panic but I am not sure which go-routine is spawned on a OS thread and which is not. Is there any way to identify that? 

The purpose of this identification is to throttle the calls that require a new OS thread to be spawned there by avoiding the thread exhaustion limit.

Thanks,
Varun

varun...@gmail.com

unread,
Jan 12, 2021, 10:50:50 AM1/12/21
to golang-nuts
Looking at all goroutines with runnable state seem to be the solution but I am not very sure about this.

goroutine 15825281 [runnable]

Reply all
Reply to author
Forward
0 new messages