[Stackless] Fwd: Google's new Go programming language

Richard Tew richard.m.tew at gmail.com
Sun Nov 15 02:45:01 CET 2009

---------- Forwarded message ----------
From: Henning Diedrich <hd at authentic-internet.de>
Date: Sun, Nov 15, 2009 at 4:20 AM
Subject: Re: [Stackless] Google's new Go programming language
To: Richard Tew <richard.m.tew at gmail.com>

Richard Tew wrote:

On Fri, Nov 13, 2009 at 4:06 AM, Henning Diedrich
<hd at authentic-internet.de> wrote:

Richard Tew wrote:

On Thu, Nov 12, 2009 at 2:56 PM, Andrew Dalke <dalke at dalkescientific.com>

On Nov 11, 2009, at 9:35 PM, Richard Tew wrote:

They have an nice example where they chain 100000 microthreads each
wrapping the same function that increases the value of a passed
argument by one, with channels inbetween.  Pumping a value through the
chain takes 1.5 seconds.  I can't imagine that Stackless will be
anything close to that, given the difference between scripting and
compiled code.

Did I mess up in my benchmark? I got about 0.07 seconds to go through
100,000 microthreads.

Interesting.  I hadn't gone to the effort of writing it yet.  I
expected the difference between a compiled language and a scripting
language to be more significant.

Well, it IS pretty impressing. Just the other way round. Was it really the
equivalent to the Go test?

It was slightly more complicated than the go test, which only sent one
value through.  The go test was in the tech talk presentation, I can't
find a text version of it to link to unfortunately.

Found it I guess:

Go benchmark:
Pg.4, http://golang.org/doc/go_talk-20091030.pdf

package main
import ("flag"; "fmt")
var ngoroutine = flag.Int("n", 100000, "how many")
func f(left, right chan int) { left <- 1 + <-right }
func main() {
    leftmost := make(chan int);
    var left, right chan int = nil, leftmost;
    for i := 0; i < *ngoroutine; i++ {
        left, right = right, make(chan int);
        go f(left, right);
    right <- 0;  // bang!
    x := <-leftmost;  // wait for completion
    fmt.Println(x);   // 100000

To contrast it on one page, here is Andrew's Stackless benchmark again:

import stackless

def source(ch):

def chain(up, down):
    for item in up:

def sink(up):
    for item in up:
        print item

def startup():
    down = stackless.channel()

    for i in range(100000):
        up = down
        down = stackless.channel()
        stackless.tasklet(chain)(up, down)


import time
t1 = time.time()
t2 = time.time()
t3 = time.time()
print "startup time:", "%.3f" % (t2-t1)
print "10 elements in:", "%.3f" % (t3-t2)

More information about the Stackless mailing list