Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Etienne Cimon via Digitalmars-d
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

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Iain Buclaw via Digitalmars-d
On 3 August 2015 at 18:27, aki via Digitalmars-d digitalmars-d@puremagic.com wrote: When I was trying to port some Java program to D, I noticed Java is faster than D. I made a simple bench mark test as follows. Then, I was shocked with the result. test results on Win8 64bit (smaller is

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Dmitry Olshansky via Digitalmars-d
On 03-Aug-2015 19:27, aki wrote: When I was trying to port some Java program to D, I noticed Java is faster than D. I made a simple bench mark test as follows. Then, I was shocked with the result. test results on Win8 64bit (smaller is better) Java(1.8.0,64bit,server): 0.677 C++(MS vs2013):

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread John Colvin via Digitalmars-d
On Monday, 3 August 2015 at 16:27:39 UTC, aki wrote: When I was trying to port some Java program to D, I noticed Java is faster than D. I made a simple bench mark test as follows. Then, I was shocked with the result. test results on Win8 64bit (smaller is better) Java(1.8.0,64bit,server): 0.677

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread John Colvin via Digitalmars-d
On Monday, 3 August 2015 at 16:47:14 UTC, Adam D. Ruppe wrote: You can try a few potential optimizations in the D version yourself and see if it makes a difference. Devirtualization has a very small impact. Test this by making `test` take `SubFoo` and making `bar` final, or making `bar` a

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Steven Schveighoffer via Digitalmars-d
On 8/3/15 12:50 PM, John Colvin wrote: On Monday, 3 August 2015 at 16:47:14 UTC, Adam D. Ruppe wrote: You can try a few potential optimizations in the D version yourself and see if it makes a difference. Devirtualization has a very small impact. Test this by making `test` take `SubFoo` and

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Adam D. Ruppe via Digitalmars-d
On Monday, 3 August 2015 at 16:47:58 UTC, John Colvin wrote: gets me down to 0.182s with ldc on OS X Yeah, I tried dmd with the final and didn't get a difference but gdc with final (and -frelease, very important for max speed here since without it the method calls are surrounded by various

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Dmitry Olshansky via Digitalmars-d
On 03-Aug-2015 19:54, Steven Schveighoffer wrote: On 8/3/15 12:50 PM, John Colvin wrote: On Monday, 3 August 2015 at 16:47:14 UTC, Adam D. Ruppe wrote: You can try a few potential optimizations in the D version yourself and see if it makes a difference. Devirtualization has a very small

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread John Colvin via Digitalmars-d
On Monday, 3 August 2015 at 16:53:30 UTC, Adam D. Ruppe wrote: On Monday, 3 August 2015 at 16:47:58 UTC, John Colvin wrote: gets me down to 0.182s with ldc on OS X Yeah, I tried dmd with the final and didn't get a difference but gdc with final (and -frelease, very important for max speed

Why Java (server VM) is faster than D?

2015-08-03 Thread aki via Digitalmars-d
When I was trying to port some Java program to D, I noticed Java is faster than D. I made a simple bench mark test as follows. Then, I was shocked with the result. test results on Win8 64bit (smaller is better) Java(1.8.0,64bit,server): 0.677 C++(MS vs2013): 2.141 C#(MS vs2013): 2.220 D(DMD

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Steven Schveighoffer via Digitalmars-d
On 8/3/15 12:31 PM, Dmitry Olshansky wrote: On 03-Aug-2015 19:27, aki wrote: When I was trying to port some Java program to D, I noticed Java is faster than D. I made a simple bench mark test as follows. Then, I was shocked with the result. test results on Win8 64bit (smaller is better)

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread John Colvin via Digitalmars-d
On Monday, 3 August 2015 at 16:41:42 UTC, Steven Schveighoffer wrote: On 8/3/15 12:31 PM, Dmitry Olshansky wrote: On 03-Aug-2015 19:27, aki wrote: When I was trying to port some Java program to D, I noticed Java is faster than D. I made a simple bench mark test as follows. Then, I was shocked

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread John Colvin via Digitalmars-d
On Monday, 3 August 2015 at 16:27:39 UTC, aki wrote: When I was trying to port some Java program to D, I noticed Java is faster than D. I made a simple bench mark test as follows. Then, I was shocked with the result. [...] What compilation flags?

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Justin Whear via Digitalmars-d
Java being fastest at running Java-style code is not too surprising. My guess is that Java is hotspot inlining the calls to `bar`, getting rid of the dynamic dispatch overhead. I think that for real systems D will generally beat out Java across the board, but not if the D version is a

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Steven Schveighoffer via Digitalmars-d
On 8/3/15 12:59 PM, Dmitry Olshansky wrote: On 03-Aug-2015 19:54, Steven Schveighoffer wrote: ALSO, make SURE you are compiling in release mode, so you aren't calling a virtual invariant function before/after every call. This one is critical. Actually why do we have an extra call for

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Adam D. Ruppe via Digitalmars-d
On Monday, 3 August 2015 at 16:50:42 UTC, John Colvin wrote: Making SubFoo a final class and test take SubFoo gives a 10x speedup for me. Right, gdc and ldc will the the aggressive inlining and local data optimizations automatically once it is able to devirtualize the calls (at least when

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Adam D. Ruppe via Digitalmars-d
You can try a few potential optimizations in the D version yourself and see if it makes a difference. Devirtualization has a very small impact. Test this by making `test` take `SubFoo` and making `bar` final, or making `bar` a stand-alone function. That's not it. Inlining alone doesn't

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread aki via Digitalmars-d
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

Re: Why Java (server VM) is faster than D?

2015-08-03 Thread Dmitry Olshansky via Digitalmars-d
On 03-Aug-2015 20:05, Steven Schveighoffer wrote: On 8/3/15 12:59 PM, Dmitry Olshansky wrote: On 03-Aug-2015 19:54, Steven Schveighoffer wrote: ALSO, make SURE you are compiling in release mode, so you aren't calling a virtual invariant function before/after every call. This one is