Why Java (server VM) is faster than D?

Etienne Cimon via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 3 11:28:59 PDT 2015


On Monday, 3 August 2015 at 17:33:30 UTC, aki wrote:
> On Monday, 3 August 2015 at 16:47:58 UTC, John Colvin wrote:
>> changing two lines:
>> final class SubFoo : Foo {
>> int test(F)(F obj, int repeat) {
>
> I tried it. DMD is no change, while GDC gets acceptable score.
> D(DMD 2.067.1): 2.445
> D(GDC 4.9.2/2.066): 0.928
>
> Now I got a hint how to improve the code by hand.
> Thanks, John.
> But the original Java code that I'm porting is
> about 10,000 lines of code.
> And the performance is about 3 times different.
> Yes! Java is 3 times faster than D in my app.
> I hope the future DMD/GDC compiler will do the
> similar optimization automatically, not by hand.
>
> Aki.

LLVM might be able to do achieve Java's optimization for your use 
case using profile-guided optimization. In principle, it's hard 
to choose which function to inline without the function call 
counts, but LLVM has a back-end with sampling support.

http://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization

Whether or not this is or will be available soon for D in LDC is 
a different matter.


More information about the Digitalmars-d mailing list