tag:blogger.com,1999:blog-15250116.post4341910007343182278..comments2013-03-02T12:38:23.550+01:00Comments on Marginally Interesting: Benchmarking javac vs. ecj on Array AccessMikio Braunhttp://www.blogger.com/profile/12784222133031101134noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-15250116.post-78311555481895578042009-05-02T14:20:00.000+02:002009-05-02T14:20:00.000+02:00Hello foobarz,
no, I haven't been able to find o...Hello foobarz,<br /> <br />no, I haven't been able to find out why there is this difference in performance. I guess there is some mismatch between what the hotspot guys optimize and the javac guys produce... .<br /><br />I also tried compiling jblas with ecj, but then the differences vanished, so I think that my benchmark from the post was rather artificial.<br /><br />Concerning jblas, version 0.1 has been released. See http://jblas.org. I also posted some benchmarking numbers http://mikiobraun.blogspot.com/2009/04/some-benchmark-numbers-for-jblas.html which show that MTJ is more or less equal to jblas except for matrix multiplication.<br /><br />Currently, I'm working on compiling the native libraries for different kinds of platforms and build a "fat-jar" so that you can use jblas without going through the admittedly complex compilation process.Mikio Braunhttps://www.blogger.com/profile/12784222133031101134noreply@blogger.comtag:blogger.com,1999:blog-15250116.post-85512283115083469812009-05-01T22:54:00.000+02:002009-05-01T22:54:00.000+02:00I just independently noticed the exact same thing ...I just independently noticed the exact same thing in one of my own benchmarks. I was comparing java to natively compiled code at accessing arrays of different primitive types. The test involved summing up the values contained in the arrays. <br /><br />The ecj compiled code ran much faster than sun's 1.6 javac, and I did use the exact same virtual machine to run them. In fact the ecj code was comparable to the native g++ -O2 code. Have you made any progress on finding out why this is?<br /><br />I'm going to try compiling some less artificial code and see if I see the same performance boost.<br /><br />Also, any progress on jBLAS? I have had the same problems with high performance java matrix libraries. I'm currently using Matrix Toolkits for Java (MTJ) as a lesser evil...Peter Abeleshttps://www.blogger.com/profile/12142642572301900181noreply@blogger.comtag:blogger.com,1999:blog-15250116.post-19514389587056681432008-08-26T16:18:00.000+02:002008-08-26T16:18:00.000+02:00Yes, I'm pretty sure that I'm using the same VM. I...Yes, I'm pretty sure that I'm using the same VM. I'm running the program just with "java -cp . Main" both times.<BR/><BR/>You're right about Client VM vs. Server VM. It seems that the default VM is the Server VM on my installation. When I run the benchmarks with "java -client ..." they both have the same runtimes.<BR/><BR/>I know that the differences in the two bytecodes are pretty marginal. So somehow, it seems that the ecj compiler manages to produce bytecode leading to better optimization when compiled to native code than the one by the javac.<BR/><BR/>I'm not quite sure what to make of this as well. It might be possible that we're missing something, or that the ecj compiler does not produce equivalent code, but currently, I don't see why.Mikio Braunhttps://www.blogger.com/profile/12784222133031101134noreply@blogger.comtag:blogger.com,1999:blog-15250116.post-19572301337804142182008-08-26T15:06:00.000+02:002008-08-26T15:06:00.000+02:00Ah, I thought the email address of a comment autho...Ah, I thought the email address of a comment author is exposed to the blog owner. Sorry.<BR/><BR/>I ran your Main.class and the result on HotSpot Client VM is the same as with the one produced by javac. <BR/><BR/>However, on HotSpot Server VM the result is:<BR/><BR/>copying array of size 1000 1000000 times... (1.860s)<BR/>syscopying array of size 1000 1000000 times using... (1.313s)<BR/>copying DoubleBuffer of size 1000 1000000 times... (LITTLE_ENDIAN) (2.312s)<BR/><BR/>I have compared the decompiled classes and I see no major difference. Are you sure you run both classes on the same JVM?Unknownhttps://www.blogger.com/profile/07636065261953938780noreply@blogger.comtag:blogger.com,1999:blog-15250116.post-73683306367742760902008-08-26T14:32:00.000+02:002008-08-26T14:32:00.000+02:00Hi dleskov,actually, you don't have to install ecl...Hi dleskov,<BR/><BR/>actually, you don't have to install eclipse, you can also just download the standalone compiler using the link in the post which is simply a jar file.<BR/><BR/>I could email the class file, but actually, I don't know your email address. I've put the class file <A HREF="http://ml.cs.tu-berlin.de/~mikio/Main.class" REL="nofollow">here</A><BR/><BR/>Anyway, with sysCopyArray I get the following numbers:<BR/><BR/>javac<BR/>copying array of size 1000 1000000 times... (3.072s)<BR/>syscopying array of size 1000 1000000 times using... (0.575s)<BR/>copying DoubleBuffer of size 1000 1000000 times... (LITTLE_ENDIAN) (4.311s)<BR/>ecj: running<BR/>copying array of size 1000 1000000 times... (0.551s)<BR/>syscopying array of size 1000 1000000 times using... (0.586s)<BR/>copying DoubleBuffer of size 1000 1000000 times... (LITTLE_ENDIAN) (0.657s)<BR/><BR/>So basically, ecj is achieving the performance of System.arraycopy().<BR/><BR/>Actually, I think I should also add that I'm doing these tests on Linux (32bit) with a Intel Core 2 T7200 at 2 Ghz. I redid some of these experiments on AMD processors and under Windows and again got again quite different numbers... .Mikio Braunhttps://www.blogger.com/profile/12784222133031101134noreply@blogger.comtag:blogger.com,1999:blog-15250116.post-91015953869484243262008-08-26T11:34:00.000+02:002008-08-26T11:34:00.000+02:00The supposedly more optimized way to copy an array...The supposedly more optimized way to copy an array is via System.arraycopy:<BR/><BR/>private static void sysCopyArray(int size, int iters) {<BR/> double[] source = new double[size];<BR/> double[] target = new double[size];<BR/> for (int i = 0; i < iters; i++) {<BR/> System.arraycopy(source, 0, target, 0, size);<BR/> }<BR/>}<BR/><BR/>On my system sysCopyArray() is about 2 times faster than copyArray() on HotSpot 1.6.0_03:<BR/><BR/>copying array of size 1000 1000000 times... (3.031s)<BR/>syscopying array of size 1000 1000000 times... (1.515s)<BR/>copying DoubleBuffer of size 1000 1000000 times... (LITTLE_ENDIAN) (17.688s)<BR/><BR/>However, on the <A HREF="http://www.excelsior-usa.com" REL="nofollow"> Excelsior JET JVM</A> there is almost no difference:<BR/><BR/>copying array of size 1000 1000000 times... (1.219s)<BR/>syscopying array of size 1000 1000000 times... (1.109s)<BR/>copying DoubleBuffer of size 1000 1000000 times... (LITTLE_ENDIAN) (15.422s)<BR/><BR/>I am most interested in finding out what difference the Eclipse compiler makes. here. I do not have Eclipse, though, and do not want to install and figure it out just for this small experiment. Can you email me the class files please?Unknownhttps://www.blogger.com/profile/07636065261953938780noreply@blogger.com