Rainer Deyke:

>The slow aspects of this garbage collector (detection and preservation) aren't 
>really tested by this benchmark.<

In practice most times real-world Java programs show a good enough performance 
even taking in account detection and preservation too.


>These are the timings without dynamic memory allocation:
>>>   D 1:   8.47 DMD [+ scope]
>>>   D 2:   7.41 DMD + scope
>>>   Java:  0.28 V.1.6.0_14, -server -XX:+DoEscapeAnalysis

It's not exactly the same, because in that Java code I have used a program-wide 
optimization flag (that I guess will become default), while in D I have had to 
add a "scope" everywhere, and I think adding "scope" is less safe than letting 
the compiler perform an escape analysis.

So I am tempted to put the 0.28 seconds result among the dynamic allocation 
timings, even if technically it is not, because for the programmer the program 
"feels" and looks and acts like a dynamic allocation, it's just faster :-) In 
the end what counts is how well the programs runs after the compiler has done 
its work.


>D's performance is unexpectedly bad, so much that I expect that it might be 
>using dynamic memory allocation anyway despite the 'scope' keyword. Java is 
>clever in that it eliminates unnecessary dynamic memory allocations 
>automatically.<

I think Java here is doing a bit more than just removing the dynamic 
allocation. I don't think D (compiled with LDC) is doing doing any allocation 
here. I'll ask to the LDC IRC channel.
I'll also take a look at the asm generated by the JavaVM (it's not handy to 
find the asm generated by the JVM, you need to install a debug version of it... 
how stupid).

-------------------------

Sam Hu:

>I am sorry to hear that,really,really sorry.<

Wait, things may not be that bad. And even if they are bad, the developers of 
the LDC compiler may find ways to improve the situation.

-------------------------

Robert Fraser:

>It suggests that for dynamic allocation of many small objects via "new", Java 
>is an order of magnitude faster than C++, which in turn is slightly faster 
>than D.<

Yes, for such tiny benchmarks I have seen several times 10-12 higher allocation 
performance in Java compared to D1-DMD. But real programs don't use all their 
time allocating and freeing memory...

Bye,
bearophile

Reply via email to