Phobos threads performance

bearophile bearophileHUGS at lycos.com
Mon Jul 21 14:16:48 PDT 2008


The Anh Tran:
> But sometime the same code gives big surprise. Ie: threadring game.

This surprises can be useful to you to learn and to the designers of D to debug it (I'm assuming such libraries have to work on both operating systems).


> > Can't you avoid the same allocation with D?
> Yes :). The D ver was targeting code beauty, not speed. :|

The Shootout site allows more than on version for each benchmark, if their purpose is different. For example here you can see two D versions:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=binarytrees&lang=all
One is mine, its purpose is to have a short and high level code, the other is for speed. The main purpose of the site is to compare speed, but it compares memory used and code complexity too.


> I have no idea. They only differ by 2 mem alloc calls.

Maybe the thread module of Phobos has some problems. But I suggest you to write a version without the memory allocations, to see how it performs. The garbage collector of D may be the fault too here.

Bye and thank you,
bearophile


More information about the Digitalmars-d-learn mailing list