View Single Post
Posts: 1,341 | Thanked: 708 times | Joined on Feb 2010
#34
Originally Posted by attila77 View Post

I see you like this link and post it over and over, but I feel obliged to tell you this is fairly old stuff - the article talks about what later became known as JIT, which did improve Java performance a lot (and later influenced modern JavaScript engines), but never quite rose to the super-fast levels promised and hoped.
Nope, this is not about JIT. I wonder if you read the study at all.

There is many optimization techniques in modern compiler science which are impossible on C/C++ because they use pointers. The whole basic structure of C/C++ should be changed to overcome the obstacles.

Heap memory fragmentation is always a problem with C++ when program uses lots of dynamic memory and is run "long" time. I suspect Firefox will never get rid of memory leaks, as long as it uses C++. There is tricks to try to avoid memory fragmentation in C, but they are much more inefficient techniques what Java JVM can do with less effort.

I think you also know the importance of L2 cache, and what are cache misses. In Java-bytecode, (live) objects can be reordered during the run-time according to usage pattern, so making L2 cache misses more rare. For C++, this is not possible, unless C++ factually is changed to be bytecode based also. JIT, and re-JITing when there is benefits in run-time, is the key in Java.
The mordern compiler technology optimizations are not yet all implemented in JVMs. Running java with "--server" settings does take some of those optimizations to use, over normal --client mode.

edit: One good book to read about subject is Modern Compiler Implementation in Java, where in the sections which talk about optimizations it introduces many techniques which are impossible to fully compiled code, but are possible when the final phase of the compiling steps are done in run-time.

I know, it seems like against common sense that interpreted code could be faster than fully compiled assembly code, but the trick is just this: "there is information which can be gathered during the run-time, which is not available in compile-time". C++ cannot use that information, Java can.

Last edited by zimon; 2010-04-16 at 20:57.