Phobos threads performance
bearophile
bearophileHUGS at lycos.com
Mon Jul 21 13:31:01 PDT 2008
The Anh Tran:
> Don't use win to write Alioth game. :(
I don't fully agree. I think a portable enough language has to allow you to compile the program on different operating systems and give you the same results. D wants to be a quite portable language. So this is one more test for the language itself.
Java generally allows me to do that, as Python.
But as you may have seen this time I have found the Psyco version may give different results (but maybe the error is mine somewhere), so I may give up on that.
Your D version works correctly on Win too.
> WaitForSingleObject is _much_ slower than pthread_mutex_lock
> I'm still changing here & there in chame.d Hope it'll better.
So how much faster is the Tango version of yours?
> D version allocate mem during the meeting loop.
> I omitted that alloc in C++ ver.
Can't you avoid the same allocation with D?
Some notes:
- Even if most people in this D newsgroups ignore the Shootout site, lot of people take a look at that site when they want to choose what language to use, so developing fast programs for that site is an important advertising. Haskell people have understood this very well, you can see it from the amount of work given in those benchmarks, they have even changed their language to improve results in some of those benchmarks:
http://www.haskell.org/haskellwiki/Great_language_shootout
- Many times I have found the Shootout site useful to learn pieces of the syntax of other languages. So I think it has a very big pedagogical purpose too. Because it shows you real non banal algorithms implemented in a very efficient way in lot of different languages. So you have to write your code well, because lot of people will learn from your code.
- Very often you can find performance problems in your language looking at how it performs compared to other languages. Here for example the threading in Phobos seems various times slower than the C++ version, that in the meantime was posted:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=chameneosredux&lang=gpp&id=0
As you can see the C++ version takes 16.7 s, while your D version needs 41 s.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list