Java Forum / General / November 2007
Java performance
borophyll@gmail.com - 04 Nov 2007 11:41 GMT I am just interested in the latest stats on Java performance. A lot of the literature appears to be out of date in this respect. Is it true that Java performance is close to that of native compiled code? I suppose it could be said that Java *is* natively compiled (at run time), but there will surely be performance penalties due to bytecode translation, at least at program startup.
Can Java be used for graphics-intensive applications, such as the latest 3D game, such as Doom/Quake/whatever is the current hot game. If not, what are the issues that prohibit Java from being suitable.
Finally, I have read that garbage collection is generally more efficient than manual memory management. Is this true, and if so, why?
Please feel free to mention anything else that is relevant...
Regards, B.
Hunter Gratzner - 04 Nov 2007 12:41 GMT On Nov 4, 12:41 pm, boroph...@gmail.com wrote:
> I am just interested in the latest stats on Java performance. A lot > of the literature appears to be out of date in this respect. Is it > true that Java performance is close to that of native compiled code? Yes.
> I suppose it could be said that Java *is* natively compiled (at run > time), but there will surely be performance penalties due to bytecode > translation, at least at program startup. Yes, at startup.
> Can Java be used for graphics-intensive applications, such as the > latest 3D game, such as Doom/Quake/whatever is the current hot game. Current? Well, there is e.g. a Quake 2 engine port to Java http://bytonic.de/html/jake2.html
There are other game engines, too. E.g. http://www.jmonkeyengine.com/
And there are other types of graphic intensive applications, too. CAD systems have been written in Java, so have GIS systems. People do complex simulations in Java and all kinds of computational intensive stuff.
> If not, what are the issues that prohibit Java from being suitable. For what? Games? Game users might be used to all kinds of long startup times, so Java's typical long startup times might not be an issue. Game users are also used to be able to use a number of HID devices (joysticks, wheels). There is a total lack of out-of-the-box support in Java for such devices. There are third-party libraries to overcome this. There is also an almost total lack of out-of-the-box integration into advanced sound engines. Java-sound does not cover all details. There are maybe third-party libraries to fix this, I am not aware of any. There is at best mediocre media support (video playing, MP3 playing). The Java media framework has been neglected for years.
What is really bad in Java is desktop integration. Interaction with native installation management or package management does not exist. All things which are closer to the system are bad. Dealing with removable media in general is bad, e.g. figuring out if a CD or DVD is in a drive can't be done with Java alone. Dealing with all kinds of system services is bad. Typical desktop I/O (serial, USB, parallel ports, Firewire) is not or badly supported.
There is only one compelling technical reason to do a desktop application in Java. When you really, really, really badly, need the cross-platform features of Java so your application runs on multiple platforms. The price you will have to pay for this is that the application will look and behave slightly alien on all supported platforms. And some things won't work at all.
> Finally, I have read that garbage collection is generally more > efficient than manual memory management. Is this true, and if so, > why? It has advantages and disadvantages. You can study the details for ages. But in short it usually doesn't hurt and is in general "better", unless you mess up things.
Lew - 04 Nov 2007 14:09 GMT boroph...@gmail.com wrote:
>> I am just interested in the latest stats on Java performance. A lot >> of the literature appears to be out of date in this respect. Is it >> true that Java performance is close to that of native compiled code?
> Yes. Or faster, sometimes.
>> Finally, I have read that garbage collection is generally more >> efficient than manual memory management. Is this true, and if so, >> why?
> It has advantages and disadvantages. You can study the details for > ages. But in short it usually doesn't hurt and is in general "better", > unless you mess up things. Whereas platforms without GC require more code to handle allocation and deallocation, and will cause trouble if you mess up things.
Allocation of a new object on the heap in Java is on the order of 10x fewer machine instructions than in C++. Deallocation of young objects, on the order of 95% of all objects in most programs (particularly if you're versed in Java idioms), is essentially zero cost.
More importantly, GC greatly reduces the window of opportunity for memory-management bugs. As Hunter says, there are ways to defeat its advantages.
Furthermore, there are multiple algorithms available. Try to duplicate the scalability of Sun's parallel GC algorithms in a non-GCed environment. The era of the single-processor computer is giving way to a multi-processor world.
Never mind how Java's GC harmonizes with Hotspot compilation.
- Lew
Knute Johnson - 04 Nov 2007 17:21 GMT > On Nov 4, 12:41 pm, boroph...@gmail.com wrote: >> I am just interested in the latest stats on Java performance. A lot [quoted text clipped - 57 lines] > ages. But in short it usually doesn't hurt and is in general "better", > unless you mess up things. The coming JRE is going to have greatly improved startup performance.
https://jdk6.dev.java.net/6uNea.html
I've played with it a little bit on windows and there does seem to be some performance increase.
 Signature Knute Johnson email s/nospam/knute/
Lew - 04 Nov 2007 19:27 GMT > The coming JRE is going to have greatly improved startup performance. > > https://jdk6.dev.java.net/6uNea.html > > I've played with it a little bit on windows and there does seem to be > some performance increase. If you really are talking about Java 6, it's been out already for almost a year.
 Signature Lew
Knute Johnson - 05 Nov 2007 01:26 GMT >> The coming JRE is going to have greatly improved startup performance. >> [quoted text clipped - 5 lines] > If you really are talking about Java 6, it's been out already for almost > a year. Read the article.
 Signature Knute Johnson email s/nospam/knute/
Roedy Green - 05 Nov 2007 03:38 GMT On Sun, 04 Nov 2007 09:21:55 -0800, Knute Johnson <nospam@rabbitbrush.frazmtn.com> wrote, quoted or indirectly quoted someone who said :
>The coming JRE is going to have greatly improved startup performance. > >https://jdk6.dev.java.net/6uNea.html "The Quick Starter feature will prefetch portions of the JRE into memory, substantially decreasing the average JRE cold start-up time (the time that it takes to launch a Java application for the first time after a fresh reboot of a PC)."
Sounds like they are loading a pre-loaded RAM image to get the basic classes going. Yea! I have been asking for this since day 1.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Lasse Reichstein Nielsen - 05 Nov 2007 06:09 GMT > On Sun, 04 Nov 2007 09:21:55 -0800, Knute Johnson > <nospam@rabbitbrush.frazmtn.com> wrote, quoted or indirectly quoted [quoted text clipped - 11 lines] > Sounds like they are loading a pre-loaded RAM image to get the basic > classes going. Yea! I have been asking for this since day 1. That, or they are making yet another "QuickStart" that loads and takes up memory at boot time, whether you use it or not. It can sit next to Office QuickStart, Firefox Quickstart and a gazillion other programs that think they are so important that you have to start everything but the GUI every time you start your machine.
/L
 Signature Lasse Reichstein Nielsen - lrn@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen - 05 Nov 2007 06:15 GMT >> On Sun, 04 Nov 2007 09:21:55 -0800, Knute Johnson >> <nospam@rabbitbrush.frazmtn.com> wrote, quoted or indirectly quoted [quoted text clipped - 18 lines] > you have to start everything but the GUI every time you start > your machine. Ack, I was hoping I was wrong. And I was, although only slightly so:
"The fix, then, is for us to take advantage of the disk cache to make sure that the memory pages on disk that we must read at startup have already been loaded before we need them. How do we do this? We cannot magically pre-load the pages just prioir to launching; unfortunately, the VM currently lacks the ability to see into the future to detect when the user will be launching Java (we would love to have this feature in the future, but it is not yet present). But we can pre-load at some earlier time, such as Windows boot or login time. And we can keep the pages warm in the disk cache as machine and memory conditions allow."
From <URL:http://weblogs.java.net/blog/chet/archive/2007/05/consumer_jre_le.html#Quickstarter>
They do load everything into memory, only cache memory instead of program memory. And they then keep hitting the pages to ensure that no cache algorithm gets to do its job. That's just being egoistical. I bet every application wants to be loaded from RAM. Well, at least I get to turn it off. /L
 Signature Lasse Reichstein Nielsen - lrn@hotpop.com DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html> 'Faith without judgement merely degrades the spirit divine.'
Patricia Shanahan - 05 Nov 2007 11:17 GMT >>> On Sun, 04 Nov 2007 09:21:55 -0800, Knute Johnson >>> <nospam@rabbitbrush.frazmtn.com> wrote, quoted or indirectly quoted [quoted text clipped - 38 lines] > loaded from RAM. Well, at least I get to turn it off. > /L One of my former jobs was project leader for the paging supervisor on a virtual storage operating system. The described "feature" makes me cringe. If every application did this, we would be forced to buy enough memory for everything to run simultaneously, rather than just for the maximum set of things we want to do at once.
Patricia
Knute Johnson - 05 Nov 2007 17:39 GMT >>>> On Sun, 04 Nov 2007 09:21:55 -0800, Knute Johnson >>>> <nospam@rabbitbrush.frazmtn.com> wrote, quoted or indirectly quoted [quoted text clipped - 47 lines] > > Patricia Isn't that Windows Vista :-).
 Signature Knute Johnson email s/nospam/knute/
Mark Space - 05 Nov 2007 21:21 GMT > Isn't that Windows Vista :-). msconfig is back in Vista, with a nice little tab where you can turn all that stuff off. I've got about 50% of mine removed, and I'm slowly working my way down to the essentials.
Except for InstallShield Dev Studio. Why does that need to be in the startup programs?
*zap*
Roedy Green - 05 Nov 2007 21:43 GMT >One of my former jobs was project leader for the paging supervisor on a >virtual storage operating system. The described "feature" makes me >cringe. If every application did this, we would be forced to buy enough >memory for everything to run simultaneously, rather than just for the >maximum set of things we want to do at once. They might avoid that problem with a java.exe command line option like this:
-preload { swing | awt | none | nogui }
"none" would be equivalent to the current behaviour.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Christian - 04 Nov 2007 14:44 GMT borophyll@gmail.com schrieb:
> I am just interested in the latest stats on Java performance. A lot > of the literature appears to be out of date in this respect. Is it [quoted text clipped - 6 lines] > latest 3D game, such as Doom/Quake/whatever is the current hot game. > If not, what are the issues that prohibit Java from being suitable. I would say problematic is that for example OpenGL needs native librarys.. calling these via jni has an overhead that will kill your performance.
The other thing which I have seen is that java may have caught up with performance.. though a little overhead stays .. specially if you not program c++ but hack c++ you can gain some bits of performance that may be relevant for one of the latest games to even run on a machine (like doing bitflipping in a pointer to traverse a list of vertices really fast).
Java is a great language but it doesn't fit for everything. Thinking Java and its features like the runtime optimization will fix everything for you in speed that the additional security like typechecking or nullpointer checking costs you is I think hybris.
> Finally, I have read that garbage collection is generally more > efficient than manual memory management. Is this true, and if so, [quoted text clipped - 4 lines] > Regards, > B. Lew - 04 Nov 2007 15:32 GMT > I would say problematic is that for example OpenGL needs native > librarys.. calling these via jni [sic] has an overhead that will kill your > performance. Well, maybe not "kill", but it will have an impact. The trick is to have the native method do enough work to make up for the overhead of the JNI barrier.
Unfortunately, you are correct about OpenGL needing JNI.
 Signature Lew
Roedy Green - 04 Nov 2007 17:53 GMT >Is it >true that Java performance is close to that of native compiled code? You have the option of native compiled code with Jet. See http://mindprod.com/jgloss/benchmark.html
Jet produces BETTER code than hand assembly.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Roedy Green - 04 Nov 2007 17:57 GMT >Can Java be used for graphics-intensive applications, such as the >latest 3D game, such as Doom/Quake/whatever is the current hot game. >If not, what are the issues that prohibit Java from being suitable. There is VolatileImage which gives you ability to rapidly bitblt inside the regen.
I have not played with Java 3D.
In the old days you poked the hardware directly with machine code. I presume today you have device drivers to access the clever parallel processing hardware in the video cards. The key would be how impedance matched the Java API is to the device driver API on any given platform. Java is always constrained my the least common denominator principle. In general, it can't use features of a platform unless all platforms support it.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Joshua Cranmer - 04 Nov 2007 19:16 GMT > I am just interested in the latest stats on Java performance. A lot > of the literature appears to be out of date in this respect. Is it > true that Java performance is close to that of native compiled code? > I suppose it could be said that Java *is* natively compiled (at run > time), but there will surely be performance penalties due to bytecode > translation, at least at program startup. In the extreme short-term (i.e., in the first few minutes), Java is going to have noticeable impact: one comparison metric gives it about 1.2-1.3 times native code (after taking startup into account). Over longer periods of time--especially if the server VM is used--Java performance is near, at, or better than native compiled code.
> Finally, I have read that garbage collection is generally more > efficient than manual memory management. Is this true, and if so, > why? In most cases, yes. Part of the problem is that manual management is manual and people are not quite as good at profiling memory as computers are. In addition, garbage collection can more easily benefit from parallel execution, a bonus in the coming days of multi-core CPUs and other parallelization techniques.
 Signature Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
Christian - 04 Nov 2007 19:32 GMT Joshua Cranmer schrieb:
>> I am just interested in the latest stats on Java performance. A lot >> of the literature appears to be out of date in this respect. Is it [quoted text clipped - 18 lines] > parallel execution, a bonus in the coming days of multi-core CPUs and > other parallelization techniques. though there seem to be other problems with compiling in java ... I once heard the term "hotspotless" code used for GUI parts written in pure java.. meaning that java's guis have the problem that they are not hot spots .. as a user won't klick each button that often resulting in gui code not being compiled down to native code but just allways being interpreted which might result in an unreactive GUI as an effect (or at least a GUI that is less reactive than a native couterpart)
Joshua Cranmer - 04 Nov 2007 20:06 GMT > .. as a user won't klick each button that often resulting in gui code > not being compiled down to native code but just allways being > interpreted which might result in an unreactive GUI as an effect (or at > least a GUI that is less reactive than a native couterpart) I don't really understand the first part of your sentence, but I can deal with the last part of it:
Unresponsive GUIs are more a symptom of poor programming skills (e.g., someone's doing too much in the EDT that could be done elsewhere) than of native-versus-non-native code problems. I have seen native GUIs become unresponsive just as much--in both Windows and Linux implementations.
In fact, from the little I know of various toolkit implementations, this is just as much a problem in Java Swing code as it is GTK2 or Windows API.
 Signature Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth
Roedy Green - 04 Nov 2007 20:06 GMT >though there seem to be other problems with compiling in java ... >I once heard the term "hotspotless" code used for GUI parts written in [quoted text clipped - 4 lines] >interpreted which might result in an unreactive GUI as an effect (or at >least a GUI that is less reactive than a native couterpart) The whole point of hotspot is you don't waste the RAM for native code or the CPU time to optimally compile unless the method is frequently used.
Sun people are primarily thinking today about server code that runs for days at time. What counts is how well it performs after the first 5 minutes of running.
The big desktop or Applet performance hit today is the time it takes to load the Java run time and hotspot hundreds of standard classes. I have suggested ever since I first encountered Java they could greatly speed up launch by precompiling a set of commonly used classes and capturing the RAM image with a process I call gespenstering I used in DOS Abundance to create relocatables out of raw RAM images.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Arne Vajhøj - 05 Nov 2007 00:03 GMT > I once heard the term "hotspotless" code used for GUI parts written in > pure java.. [quoted text clipped - 3 lines] > interpreted which might result in an unreactive GUI as an effect (or at > least a GUI that is less reactive than a native couterpart) I find it hard to believe that the effect of like 20 statements in an actionPerformed being JIT'ed or not should be noticeable.
A difference between 1 micro second and 20 microseconds is relative big. But a GUI user needs damn sharp eyes to notice the difference.
Arne
Roedy Green - 04 Nov 2007 20:01 GMT On Sun, 04 Nov 2007 19:16:25 GMT, Joshua Cranmer <Pidgeot18@verizon.invalid> wrote, quoted or indirectly quoted someone who said :
>In the extreme short-term (i.e., in the first few minutes), Java is >going to have noticeable impact: one comparison metric gives it about >1.2-1.3 times native code (after taking startup into account). Over >longer periods of time--especially if the server VM is used--Java >performance is near, at, or better than native compiled code. On an older machine you will notice a difference the Swing GUI makes. It has an extra layer of overhead between the application and the hardware. With a 2 GHz machine you likely won't notice it. It as fast enough to keep up with a human.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Sherman Pendley - 04 Nov 2007 23:36 GMT > I am just interested in the latest stats on Java performance. A lot > of the literature appears to be out of date in this respect. Is it > true that Java performance is close to that of native compiled code? True in many cases, yes.
> I suppose it could be said that Java *is* natively compiled (at run > time), but there will surely be performance penalties due to bytecode > translation, at least at program startup. That's one reason that Java is currently far more popular for long-running server applications than it is for browser applets or desktop apps. Startup time isn't such a big deal when the app is rarely killed and restarted.
> Can Java be used for graphics-intensive applications, such as the > latest 3D game, such as Doom/Quake/whatever is the current hot game. > If not, what are the issues that prohibit Java from being suitable. I've quite a bit of experience in cross-language development (see my .sig), and in my experience the cost of crossing the language barrier tends to be pretty high. That doesn't make Java unsuitable for high-performance 3D apps, it just means you need to carefully think about and manage how your Java code calls the low-level 3D rendering functions.
> Finally, I have read that garbage collection is generally more > efficient than manual memory management. Is this true, and if so, > why? It's easier than some manual schemes, and about on par with others. It's definitely easier than old-school malloc()/free(). But, there are "semi- manual" techniques such as those used in C++ (stack-based objects and STL collections) or Objective-C (autorelease pools and design patterns that support them) that are also much easier than the old-school approach.
Sun likes to pretend that the old-school approach is the only possible alternative to Java, so as to make Java look better in comparison. The truth isn't as black-and-white as that.
sherm--
 Signature WV News, Blogging, and Discussion: http://wv-www.com Cocoa programming in Perl: http://camelbones.sourceforge.net
borophyll@gmail.com - 05 Nov 2007 06:06 GMT On Nov 4, 9:41 pm, boroph...@gmail.com wrote:
> I am just interested in the latest stats on Java performance. A lot > of the literature appears to be out of date in this respect. Is it [quoted text clipped - 15 lines] > Regards, > B. Thanks all for the responses. The feeling I am getting is that Java is not very suitable for apps where it needs to interact quite closely with the machine (such as graphics, device I/O) because of large runtime overhead of JNI. Can this overhead be circumvented by compiling Java to native code? Or is it unavoidable for some reason..
Does Java suffer from GC pauses anymore(on UP systems), or are they a thing of the past?
<OT> I am looking for a language that is as close to the metal as C++, yet has garbage collection, which I think is a better idea than manual mm. Any ideas? </OT>
Sherman Pendley - 05 Nov 2007 09:30 GMT > <OT> I am looking for a language that is as close to the metal as C++, > yet has garbage collection, which I think is a better idea than manual > mm. Any ideas? </OT> Try C++.
No - I'm not joking. So-called "manual" memory management isn't half as bad as Sun's marketing makes it out to be. Newer tools, libraries, and design patterns have made manual new() and delete() calls a rarity. If you think MM in C++ is entirely manual, or painful to use, then odds are good that you're either misusing it, or haven't written any C++ in quite a few years.
Don't get me wrong - I like Java, and use it regularly. But if what you need is C++ with GC, then you can have precisely that.
sherm--
 Signature WV News, Blogging, and Discussion: http://wv-www.com Cocoa programming in Perl: http://camelbones.sourceforge.net
borophyll@gmail.com - 05 Nov 2007 10:47 GMT > boroph...@gmail.com writes: > > <OT> I am looking for a language that is as close to the metal as C++, [quoted text clipped - 6 lines] > bad as Sun's marketing makes it out to be. Newer tools, libraries, and > design patterns have made manual new() and delete() calls a rarity. Perhaps, but are they as efficient as a language which has GC built in and was designed to be GC'd. Are these C++ GC libraries just manual MM hidden behind classes/templates, or do they truly support "proper" GC. This question seems to be important, because I have read that GC done properly is more efficient than manual mm.
Sherman Pendley - 05 Nov 2007 13:20 GMT >> boroph...@gmail.com writes: >> > <OT> I am looking for a language that is as close to the metal as C++, [quoted text clipped - 12 lines] > GC. This question seems to be important, because I have read that GC > done properly is more efficient than manual mm. GC proponents invariably compare it to malloc()/free() or new()/delete(). That's accurate as far as it goes, but it's a pointless comparison because modern C++ code hardly ever relies on such low-level memory management to begin with.
Here's a pretty good review of GC options in C++:
<http://www.iecc.com/gclist/GC-faq.html>
sherm--
 Signature WV News, Blogging, and Discussion: http://wv-www.com Cocoa programming in Perl: http://camelbones.sourceforge.net
Lew - 05 Nov 2007 14:38 GMT > Thanks all for the responses. The feeling I am getting is that Java > is not very suitable for apps where it needs to interact quite closely > with the machine (such as graphics, device I/O) because of large > runtime overhead of JNI. Can this overhead be circumvented by > compiling Java to native code? Or is it unavoidable for some reason.. I don't know. Jake2 achieves 200+ frames/s. Pretty fast for a Java program, eh?
> Does Java suffer from GC pauses anymore(on UP systems), or are they a > thing of the past? "Suffer"?
Of course there are GC pauses, but there are a variety of ways to minimize their impact. The generational collector does a pretty darn good job of keeping GC pauses to a minimum.
How long does it take to free memory in a non-GC language?
If memory is to be freed, it will take time. We don't notice it if that time is amortized properly over the program run, as, say, with Java's GC mechanism.
> <OT> I am looking for a language that is as close to the metal as C++, > yet has garbage collection, which I think is a better idea than manual > mm. Any ideas? </OT> I suggest Java.
 Signature Lew
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|