how lightweight are goroutines?

838 views
Skip to first unread message

Aaron Yodaiken

unread,
Jul 1, 2010, 2:08:16 AM7/1/10
to golang-nuts
I know they're lightweight—but how so? Are there any good benchmarks
that you have for goroutine performance? And is the current model of
implementation (I understand them to be green threads in a predefined
threadpool…is that correct?) likely to change anytime soon?

Thanks so much—Go seems pretty great.

Jessta

unread,
Jul 1, 2010, 3:11:10 AM7/1/10
to Aaron Yodaiken, golang-nuts

"To make the stacks small, Go's run-time uses segmented stacks. A
newly minted goroutine is given a few kilobytes, which is almost
always enough. When it isn't, the run-time allocates (and frees)
extension segments automatically "
http://golang.org/doc/go_lang_faq.html#goroutines

also, http://research.swtch.com/2010/03/broken-abstractions-in-go.html
has some information about how the 'go' keyword works and the overhead
of spawning a goroutine compared to making a regular function call.

- jessta

--
=====================
http://jessta.id.au

Aaron Yodaiken

unread,
Jul 1, 2010, 12:24:39 PM7/1/10
to golang-nuts
That cleared things up. Thanks Jessta.

On Jul 1, 2:11 am, Jessta <jes...@gmail.com> wrote:
> On Thu, Jul 1, 2010 at 4:08 PM, Aaron Yodaiken <a...@remura.org> wrote:
> > I know they're lightweight—but how so? Are there any good benchmarks
> > that you have for goroutine performance? And is the current model of
> > implementation (I understand them to be green threads in a predefined
> > threadpool…is that correct?) likely to change anytime soon?
>
> > Thanks so much—Go seems pretty great.
>
> "To make the stacks small, Go's run-time uses segmented stacks. A
> newly minted goroutine is given a few kilobytes, which is almost
> always enough. When it isn't, the run-time allocates (and frees)
> extension segments automatically "http://golang.org/doc/go_lang_faq.html#goroutines
>
> also,http://research.swtch.com/2010/03/broken-abstractions-in-go.html

Andrea Fazzi

unread,
Jul 1, 2010, 4:31:31 PM7/1/10
to golang-nuts
Excerpts from Aaron Yodaiken's message of gio lug 01 08:08:16 +0200 2010:

I don't know if it can considered a good benchmark btw I got these results
when I compared Go goroutines spawning times against Erlang processes ones:

http://remogatto.github.com/go-benchmarks/

The time to spawn a goroutine seems an order of magnitude lower than the
time to spawn an Erlang process. Above all, the time to create an Erlang
process seems to increase when the number of spawned processes increases.

Cheers,
Andrea

--
Andrea Fazzi @ alcacoop.it
Read my blog at http://freecella.blogspot.com
Follow me on http://twitter.com/remogatto

Reply all
Reply to author
Forward
0 new messages