On Wed, 6 Oct 2021, 18:38 Renat Idrisov, <parsifal...@gmail.com> wrote:


... I do use a lots of gorotines,
> but I supposed they are not mapped to OS threads that frequently.
>

The runtime attempts to limit the number of OS threads to the value of
GOMAXPROCS. However, some threads do not count against that budget, namely
CGo calls that have to execute in a dedicated OS thread because a goroutine
stack might be not big enough for running C code in the general case. If
there are many goroutines doing CGo calls it may explain your observations.

>

> Correct me if I am wrong, as far as I know there is no way to recycle them.
>

I'm not sure on this. I think OS threads are not destroyed by the runtime,
but parked and reused when a new one is needed.

>

> Is it correct that any IO to socket or file makes gorotine an OS thread?
>

I think some syscalls spawn a thread when they do not return within
some time limit.

What about mutexes and sleeps?
>

Those should be safe AFAICT. But I know very little about the runtime above
some basic concepts.

>

> I can rethink the architecture to do all IO from dedicated gorotines,
> but need to confirm the list of "forbidden" operations.
>

I hope some expert will chim in and provide an authoritative answer to this.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-WXKqY5899iTg3L0%3DSYWqQZwExAWsRt%2BS3q9%3DwQWzbOPw%40mail.gmail.com.

Reply via email to