Google Groups Home
Help | Sign in
Message from discussion Optimise my ray tracer
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Jon Harrop  
View profile
 More options 11 Jun 2005, 01:56
Newsgroups: comp.lang.java.programmer
From: Jon Harrop <use...@jdh30.plus.com>
Date: Sat, 11 Jun 2005 01:56:16 +0100
Local: Sat 11 Jun 2005 01:56
Subject: Re: Optimise my ray tracer

Chris Smith wrote:
> Jon Harrop <use...@jdh30.plus.com> wrote:
>> Can you elaborate on this? All of my tests indicate that Java is many
>> times slower than most other modern languages, even stereotypically slow
>> languages like SML and OCaml.

> You're making statements that are far too broad to be useful.  Java is
> far slower doing what?

Running my ray tracer.

> Most computational tasks tend to run within about 10% to 20% of optimal
> time for the hardware platform, and compare about evenly with modern
> compiled languages.

If you're trying to say that equivalent programs written in different
languages like C, C++, Java, SML, OCaml and Fortran will be within 20% of
each other's performance then that definitely isn't true. Any programs
which stress allocation/deallocation (e.g. balanced binary trees) are
likely to do significantly worse in garbage collected languages. Any
programs which stress indirected data structures will do significantly
worse in OCaml, particularly when pointers cost 64 bits.

> There are specific tasks for which significant
> general performance differences may be measured (floating point
> calculations being one, but I can't recall whether Java is typically
> faster or slower here, and it may depend on the platform), but this
> wouldn't be described as "many times slower".

Here are the times for running my ray tracer on x86 (1.2GHz Athlon T-bird)
with n=128, level=6 and ss=4:

Mlton    1.250s  mlton ray.sml
IFC      1.361s  ifort -O3 -u -static-libcxa -o raytracer raytracer.f90
C++      1.555s  g++-3.4 -O3 -march=athlon-tbird -ffast-math ray.cpp -o ray
ocamlopt 1.932s  ocamlopt -inline 100 ray.ml -o ray
SML-NJ   2.085s  sml ray.sml
G95      3.351s  g95 -O3 -ffast-math ray.f90 -o ray
C        4.125s  gcc-3.4 -lm -std=c99 -O3 -march=athlon-tbird
-funroll-all-loops -ffast-math ray.c -o ray
Java     6.492s  javac ray.java
GCJ     20.316s  gcj-3.4 --main=ray -Wall -O3 -march=athlon-tbird
-funroll-all-loops -ffast-math ray.java -o ray
ocamlc  41.047s  ocamlc ray.ml -o ray

as you can see, Java run under Sun's J2SE is over 5x slower than the fastest
implementation (Mlton-compiled SML).

> I strongly suspect that the issue is startup time.

I have taken many measurements for different running times (<2s to >20s)
and, assuming Java's startup time to be constant, the startup time is
insignificant.

> If you're measuring
> it with your ray tracer, are you measuring externally so as to include
> the startup time, or internally once the VM has started?  There's no
> "right" way to do this; it depends on whether your target audience will
> care about startup time, or only how the appo performs once it's
> running.  However, if you're including startup time, you ought to at
> least add a note that this is the reason for the results.  The great
> majority of applications run for orders of magnitude longer than the
> average benchmark, and just saying that Java is slower is very
> misleading.

Right, well I've accounted for that and I can still only conclude that Java
is very slow.

I've also run the ray tracer on AMD64 with JDK 1.5 and Java is still
significantly slower than other languages, albeit "only" 2.4 times slower.

--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google