<story><title>Goroutines are not significantly lighter than threads</title><url>https://matklad.github.io//2021/03/12/goroutines-are-not-significantly-lighter-than-threads.html</url></story><parent_chain></parent_chain><comment><author>jchw</author><text>Not only does 3x seem quite significant, but thread context switches are also a large overhead and that goes untested here. If thread context switch overhead was as low as usermode context switching, there would be no use for coroutines since you could just use threads instead; I doubt it’s non-trivial.&lt;p&gt;(Of course, in Go, the scheduler also weaves in the GC IIRC, so an apples-apples comparison may be difficult. Micro benchmarks are just not that useful.)&lt;p&gt;P.S.: this article seems to work under the assumption that 10,000 Goroutines is a reasonable upper limit, or at least it feels as though it implies that. However, you can definitely run apps with 100,000 or even 1,000,000.</text></comment>
<story><title>Goroutines are not significantly lighter than threads</title><url>https://matklad.github.io//2021/03/12/goroutines-are-not-significantly-lighter-than-threads.html</url></story><parent_chain></parent_chain><comment><author>networkimprov</author><text>I think there&amp;#x27;s a bug, tho it might not make a difference to the results:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    for i := 0; i &amp;lt; 10; i++ {
       go func() {
          f(i) &amp;#x2F;&amp;#x2F; sees whatever value i has when f() is called, usually 10
       }()
    }&lt;/code&gt;&lt;/pre&gt;</text></comment>