Andrew Dalke compares Go and Stackless Python and gets some very interesting results.
I'd like to see answers to some of the questions he raises.
Why does Pike emphasize the performance of Go's goroutine creation and channel communication when it seems to be slower than Stackless and definitely is not an order of magnitude faster?
Why indeed? Please answer us Google Engineers!
Update:Just for fun, I ran the benchmarks myself, and added a benchmark for Fibra, because I wrote it, and I know that it is pretty slow. :-)
Go...
wdgt:tmp simon$ time ./6.out
100000
real 0m1.147s
user 0m0.646s
sys 0m0.491s
Stackless...
wdgt:tmp simon$ time python sgo.py
100000
real 0m0.532s
user 0m0.448s
sys 0m0.080s
Fibra...
wdgt:tmp simon$ time python fgo.py
100000
real 0m4.054s
user 0m3.883s
sys 0m0.153s
This is the Fibra benchmark code. It's almost the same as the Stackless example, except for the ugly "yield" statements.
import fibra
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-n", type="int", dest="num_tasklets", help="how many", default=100000)
def f(left, right):
x = yield right.pop()
yield left.push(x+1)
def main():
options, args = parser.parse_args()
leftmost = fibra.Tube()
left, right = None, leftmost
for i in xrange(options.num_tasklets):
left, right = right, fibra.Tube()
schedule.install(f(left, right))
yield right.push(0)
x = yield leftmost.pop()
print x
schedule = fibra.schedule()
schedule.install(main())
schedule.run()
The results are: Stackless fast, Go slow, Fibra... forget it.