[MUD-Dev] Java on Linux
abies at adres.pl
Wed Dec 3 19:52:08 New Zealand Daylight Time 2003
> I am attempting to write a server from scratch, and will probably
> be using Java. My question is, does compiling Java to native code
> (using the GNU tool for doing it under Linux (I think it is called
> gij?)) really enhance the speed very much? Or does it just cut
> down on memory usuage?
It is called gcj.
As for the speed, it depends. In few places you will get reasonable
speedup (but nothing like x2, think about tens of percent). In many
cases it works with similar speed or slightly slower. In some
pathological cases it is umpteen times slower. Of course I'm
assuming here that you take reasonable jvm+options here, there is a
plenty of places for making mistake here.
One of main problems is that gcj lags behind recent JDK as far as
core class library is concerned. If you don't use missing parts it
is non-issue, if you do, you can try to develop missing
functionality yourself (it is open source after all) or try out
commercial solution like jet (http://excelsior-usa.com/home.html),
which supports latest JDK versions.
Generally, as far as you look at speed alone (benchmark-like
things), static compilers are not so good as they should be. IBM/Sun
jvms are really state of art, do some things which are hard for
static compilers (like speculative virtual call inlining), have very
good, precise gc - hard to beat with any static compiler.
Static compilation has other benefits. You can produce single
executable, which is easy to deploy - no dependencies on jvm
installed, just click and run (or type and run in case of
linux...). If you count size of full JRE, static executable will be
smaller. If it is run few times, program code can be shared by OS,
instead of being fully duplicated for each instance. You can also
reduce startup time considerably. Memory usage of process itself
will be smaller for exec part, but as far as heap is concerned, you
are basically in same area.
None of these reasons is really important if your want to run a
server yourself. IBM or Sun jdk will serve you perfectly until very
late stages of project. THEN you can try to compile it with gcj and
jet and see if it helps and consider costs of for example buying jet
license versus adding few cheap servers to cluster.
You may want to look for example at
where they compare jet with Sun JDK 1.4.1. They use Sun JDK client,
which is slower then server and still are only around 10% faster. With
server version, there is a chance it would get other way around... For
differences between different jvms,
is probably a good reference.
MUD-Dev mailing list
MUD-Dev at kanga.nu
More information about the MUD-Dev