Originally posted by: kamper
You're saying gcj is significantly slower than sun's jvm? Any particular reason for that, beyond less advanced optimizations?
i wouldn't say less advanced optimizations.. rather a lack of.
I've seen some benchmarks indicating that gcj is often slower, but I also don't understand why. Doesn't the JVM have to spend time compiling in real time? How does it make up for this time?
gcj is slow at runtime checks (array boundary, dynamic type, etc...).
it doesn't compile everything.. with an adaptive compiler, it runs the code through the interpreter, and profiles the code, looking for execution hotspots.. which are then compiled into native machine code and stored in memory.
Also, people often complain about Java being relatively slow. I always thought that was because of processing time used by the JVM. But the fact that GCJ doesn't run faster seems to indicate this isn't the reason. So why is Java slower compared to other languages?
the jvm can't compensate for bad code or bad startup options..
if the initial heap size is too small, the jvm has to allocate a larger heap, a slow process. if the heap size is too large, the os may page out portions of the heap.
if the programmer keeps references to objects that are no longer used, the garbage collector can't reclaim the memory.
if a method from one class will never be overriden by a base class, but doesn't have the final modifier.. inlining will be less efficient.