Slashdot Mirror


Book Review: Java Performance

jkauzlar writes "The standard Oracle JVM has about sixty 'developer' (-XX) options which are directly related to performance monitoring or tuning. With names such as 'UseMPSS' or 'AllocatePrefetchStyle', it's clear that Joe Schmo Code Monkey was not meant to be touching them, at least until he/she learned how the forbidding inner recesses of the JVM work, particularly the garbage collectors and 'just-in-time' compiler. This dense, 600-page book will not only explain these developer options and the underlying JVM technology, but discusses performance, profiling, benchmarking and related tools in surprising breadth and detail. Not all developers will gain from this knowledge and a few will surrender to the book's side-effect of being an insomnia treatment, but for those responsible for maintaining production software, this will be essential reading and a useful long-term reference." Keep reading for the rest of jkauzlar's review. Java Performance author Charlie Hunt and Binu John pages 693 publisher Addison Wesley rating 9/10 reviewer Joe ISBN 0-13-290525-6 summary Java performance monitoring and tuning In my experience, performance tuning is not something that is given much consideration until a production program blows up and everyone is running around in circles with sirens blaring and red lights flashing. You shouldn't need a crisis however before worrying about slow responsiveness or long pauses while the JVM collects garbage at inconvenient times. If there's an opportunity to make something better, if only by five percent, you should take it, and the first step is to be aware of what those opportunities might be.

First off, here's a summary of the different themes covered:

The JVM technology: Chapter 3 in particular is dedicated to explaining, in gory detail, the internal design of the JVM, including the Just-In-Time Compiler and garbage collectors. Being requisite knowledge for anyone hoping to make any use of the rest of the book, especially the JVM tuning options, a reader would hope for this to be explained well, and it is.

JVM Tuning: Now that you know something about compilation and garbage collection, it's time to learn what control you actually have over these internals. As mentioned earlier, there are sixty developer options, as well as several standard options, at your disposal. The authors describe these throughout sections of the book, but summarize each in the first appendix.

Tools: The authors discuss tools useful for monitoring the JVM process at the OS level, tools for monitoring the internals of the JVM, profiling, and heap-dump analysis. When discussing OS tools, they're good about being vendor-neutral and cover Linux as well as Solaris and Windows. When discussing Java-specific tools, they tend to have bias toward Oracle products, opting, for example, to describe NetBean's profiler without mentioning Eclipse's. This is a minor complaint.

Benchmarking: But what good would knowledge of tuning and tools be without being able to set appropriate performance expectations. A good chunk of the text is devoted to lessons on the art of writing benchmarks for the JVM and for an assortment of application types.

Written by two engineers for Oracle's Java performance team (one former and one current), this book is as close to being the de facto document on the topic as you can get and there's not likely to be any detail related to JVM performance that these two men don't already know about.

Unlike most computer books, there's a lot of actual discussion in Java Performance, as opposed to just documentation of features. In other words, there are pages upon pages of imposing text, indicating that you actually need to sit down and read it instead of casually flipping to the parts you need at the moment. The subject matter is dry, and the authors thankfully don't try to disguise this with bad humor or speak down to the reader. In fact, it can be a difficult read at times, but intermediate to advanced developers will pick up on it quickly.

What are the book's shortcomings?

Lack of real-world case studies: Contrived examples are provided here and there, but I'm really, seriously curious to know what the authors, with probably two decades between them consulting on Java performance issues, have accomplished with the outlined techniques. Benchmarking and performance testing can be expensive processes and the main question I'm left with is whether it's actually worth it. The alternatives to performance tuning, which I'm more comfortable with, are rewriting the code or making environmental changes (usually hardware).

3rd Party tool recommendations: The authors have evidently made the decision not to try to wade through the copious choices we have for performance monitoring, profiling, etc, with few exceptions. That's understandable, because 1) they need to keep the number of pages within reasonable limits, and 2) there's a good chance they'll leave out a worthwhile product and have to apologize, or that better products will come along. From my point of view, however, these are still choices I have to make as a developer and it'd be nice to have the information with the text as I'm reading.

As you can see, the problems I have with the book are what is missing from it and not with what's already in there. It's really a fantastic resource and I can't say much more than that the material is extremely important and that if you're looking to improve your understanding of the material, this is the book to get.

You can purchase Java Performance from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

160 comments

  1. Dead trees == outdated as soon as printed by idontgno · · Score: 4, Informative

    It seems this kind of volatile deep non-documented black magic might change radically from JVM revision to revision. Although the Oracle "documentation" page seems to contain a lot of "legacy" options, there still seems a risk that this book would be outdated as soon as the next JVM release.

    Oh, well, the tech publishing industry seems to be doing pretty well, even if the rate of technology change means that a tech fact is OBE before it's committed to ink.

    --
    Welcome to the Panopticon. Used to be a prison, now it's your home.
    1. Re:Dead trees == outdated as soon as printed by MightyMartian · · Score: 4, Informative

      Indeed. These sorts of options are so version dependent (not even going to alternative implementations) that I think the overwhelming majority of developers would want to stay far away from this sort of book.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    2. Re:Dead trees == outdated as soon as printed by idontgno · · Score: 2

      And, in good Slashdot form, replying to myself (explain again why don't we have an "edit" button?), I read on the very Oracle web page I cited earlier:

      Options that are specified with -XX are not stable and are not recommended for casual use. These options are subject to change without notice.

      So, the "-XX" options are unstable and are subject to change without notice, which is why we have to commit them to a $25 to $35 pile of dead trees.

      --
      Welcome to the Panopticon. Used to be a prison, now it's your home.
    3. Re:Dead trees == outdated as soon as printed by MightyMartian · · Score: 0, Troll

      Why in the fuck was I modded troll? I guess the repugnant little asshats pushing this book must have some points. Fucking worthless pathetic immoral assfuckers.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    4. Re:Dead trees == outdated as soon as printed by DiegoBravo · · Score: 4, Informative

      Apparently just the chapter 7 is about the XX:

        Chapter 1: Strategies, Approaches, and Methodologies, Chapter 2: Operating System Performance Monitoring, Chapter 3: JVM Overview, Chapter 4: JVM Performance Monitoring, Chapter 5: Java Application Profiling, Chapter 6: Java Application Profiling Tips and Tricks, Chapter 7: Tuning the JVM, Step by Step, Chapter 8: Benchmarking Java Applications, Chapter 9: Benchmarking Multitiered Applications, Chapter 10: Web Application Performance, Chapter 11: Web Services Performance, and Chapter 12: Java Persistence and Enterprise Java Beans Performance.

      BTW, of course you should avoid the XX options, but when in need, it is better to have some authoritative reference than having to rely on the uninformative Oracle docs or random forums.

    5. Re:Dead trees == outdated as soon as printed by rezalas · · Score: 2, Insightful

      Why in the fuck was I modded troll?

      Good question, but this follow up statement may be holding a clue:

      I guess the repugnant little asshats pushing this book must have some points. Fucking worthless pathetic immoral assfuckers.

      Yeah, that blurb didn't help ya.

    6. Re:Dead trees == outdated as soon as printed by Anonymous Coward · · Score: 0

      I'm guessing your winning personality had something to do with it. Try not sounding like a three year old with Tourette's if you'd like people to respect your opinion. In fact, judging by your post history I'm wondering why it is you're confused people judged you a troll in the first place, it's obviously not the first time.

    7. Re:Dead trees == outdated as soon as printed by medv4380 · · Score: 1

      How many years were we on Java6 before Java7 came out?

    8. Re:Dead trees == outdated as soon as printed by fusiongyro · · Score: 3, Interesting

      They're not going to throw out the JVM and rewrite it from scratch between releases. If there are 60 options now, there may be 66 in the next release. That means 90% of the book is still useful and the other 10% is just missing.

      On top of that, as the reviewer clearly states "Unlike most computer books, there's a lot of actual discussion in Java Performance, as opposed to just documentation of features.... there are pages upon pages of imposing text, indicating that you actually need to sit down and read it...". So this book is already the kind of book that isn't going to be overturned by one more JVM release. It may contain actual wisdom rather than a list of flags.

    9. Re:Dead trees == outdated as soon as printed by microbox · · Score: 0

      You have been the best entertainment all day. Let me guess -- the girls just /love/ you =0

      --

      Like all pain, suffering is a signal that something isn't right
    10. Re:Dead trees == outdated as soon as printed by Anonymous Coward · · Score: 0

      It is not only version dependency, there is a problem with optimization in general. That is if a system is highly optimized for a particular configuration it is not robust because configurations often change. Processor speed, memory size, operating system types, etc vary so optimizing for a particular setup is usually a bad idea. What we want are low Q systems whose performance is stable across a variety of configurations. A fine tuning knob on an old TV is a sign of immature technology not a feature.

    11. Re:Dead trees == outdated as soon as printed by Lord+Byron+II · · Score: 1

      Exactly. Take even the simplest Linux command, like 'rm'. Now look at this excerpt from the man page:

      --no-preserve-root
                                  do not treat `/' specially

      What does that mean? That little blurb really isn't sufficient to learn what that option does. If you already are familiar with rm, then that blurb will likely remind you of the intended action. Unfortunately, the goal of a lot of online documentation is to refresh your memory, not teach. That's why you need good dead tree documentation. That way, even if they make some minor changes in the future, you'll still have a good solid understanding of the way the system works in the first place.

    12. Re:Dead trees == outdated as soon as printed by Anonymous Coward · · Score: 0

      And, in good Slashdot form, replying to myself (explain again why don't we have an "edit" button?), I read on the very Oracle web page I cited earlier:

      Options that are specified with -XX are not stable and are not recommended for casual use. These options are subject to change without notice.

      So, the "-XX" options are unstable and are subject to change without notice, which is why we have to commit them to a $25 to $35 pile of dead trees.

      A lot of -XX options are probably with us forever (though they may "move" the option and make it not a -XX option in the future). Things such as PermGenSpace flags are critical and are never going away so long as Java works the way it does. I don't know anything about this book but you'd be hard pressed to find even 1 in 50 Java guys that really, truly understand the guts of this stuff. This is the kind of book the minority uses as a solid reference, I suspect.

  2. Book details correct? by Anonymous Coward · · Score: 0

    I want to purchase, but I see a book with the same title, but different ISBN, and different number of pages on amazon. Can you double check these values?

    1. Re:Book details correct? by gweihir · · Score: 1

      May be an Amazon fraudster trying to ride on this. Better be sure before you buy.

      --
      Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  3. Currently reading by Anonymous Coward · · Score: 2, Informative

    The development team at my company is currently reading this book. I'm three chapters in, and am having a hard time following it all. I often have to reread paragraphs, or entire pages, as soon as I finish them just to keep terms and names straight. Some applications which are discussed are five words long, like Microsoft Process Performance Analysis Console, or something head-spinning like that. That's the actual name of the application, so there is no other way to refer to it, so it's just the nature of the material. It's a good reference, and I'd highly recommend reading it if you work with Java full-time. The information for debugging and fixing performance issues is invaluable. Just be sure to take your Ritalin or Adderall before hand.

  4. Re:Futile by helixcode123 · · Score: 0

    That's what JNI is for. Write your performance-critical code in C.

    --

    In a band? Use WheresTheGig for free.

  5. Re:Futile by Desler · · Score: 1

    Sure if you can stand the pain and ugliness of using JNI.

  6. Re:Futile by Anonymous Coward · · Score: 1

    No, it's more like raising the efficiency of your diesel 18-wheeler by a few mpg and pocketing the savings.

  7. Re:Futile by Anonymous Coward · · Score: 0

    Nicely played. Let's see if you get any bites!

  8. Re:Futile by mhh91 · · Score: 3, Informative

    If you don't like JNI, you can use SWIG, it generates JNI code for you.

  9. Re:lol java weenies by Anonymous Coward · · Score: 2, Informative

    Loser: Javascript != Java

  10. Re:Futile by Anonymous Coward · · Score: 1

    I'd just like to point out that often even economy cars are worth upgrading for performance because car-makers often hamper their own designs for various reasons (e.g., severely under-dampening the suspension).

    Also, do any JREs actually support NIO direct buffers*? I tried it on OS X and Amazon's Karmic 64 nodes about a year and a half ago and it didn't work, thus doubling my memory and severely hampering a project (since I unfortunately had to program sockets for the first time in over a decade and was advised to go with Java over C). Unless distributions actually support direct buffers, using C in Java is much worse than it needs to be.
    *I think that's the right term for sharing memory between C and Java.

  11. Re:lol java weenies by Anonymous Coward · · Score: 0

    You're confusing ECMAScript (JavaScript) with Java. You should know what you're talking about before you make a fool out of yourself again.

  12. Re:Futile by Anonymous Coward · · Score: 2, Interesting

    I'm working on the inverse right now. Porting C code to Java and improving it. It does take longer to run, but it's also doing a lot more. However, setting up a worker thread pool in java is much easier than doing threading in C. With the -server flag and some tuning for max ram usage, it can do a reasonable amount of work. Of course the RAM needed for the program is much larger than it's C counterpart.

  13. Re:60 options? by Pieroxy · · Score: 2

    They should be 0. Or maybe 1. This just proves that Java is a piece of shit in every regard.

    20 words to say that? There should be 0. Or maybe one. This just proves that AC is a piece of shit in every regard.

  14. Re:Futile by Ichoran · · Score: 5, Insightful

    There is a _big_ difference between clumsily optimized (or unoptimized) Java and carefully-optimized Java--more, in my experience, than the difference between clumsily optimized Java and clumsily optimized C or C++. So if you are already using Java for some reason (robustness to faults, ease of parallelism of certain kinds (w.r.t. C), library that does exactly what you need, etc.), you should figure out how to optimize it before bailing out and using a different language.

    Only if you absolutely must get as much out of your hardware as physically possible should you start using C/C++, and at that point, don't expect to be using ANSI C; you should be issuing SSE4 instructions and such (basically writing targeted assembly, even if you are doing so in a way that looks like C functions) that have been cleverly crafted to do exactly what you need.

    (And don't forget that while you are taking extra time to write all this low-level high-performance code, your computers _could_ have been running using the slower code, making progress towards a solution, or serving customers albeit with delays, etc..)

  15. How much difference do these options really make? by naasking · · Score: 2

    I can see the use for options to specify heap sizes, and to tweak latency vs. throughput of the GC. These are critical for memory-constrained and timing-constrained applications, respectively. I presume the other options are performance related, but how effective are they really?

  16. java se or java ee? by edxwelch · · Score: 1

    I wonder what type of projects would need to tweek the jvm. I am assuming it's huge java web based enterprise applications.

  17. Re:How much difference do these options really mak by DalDei · · Score: 4, Funny

    -XX11 is useful as its +1 faster than -XX10, should be the default really.

  18. Too many options by medv4380 · · Score: 4, Insightful

    The JVM really needs to get smarter. 60 different controls and switches is just too much. How hard can it be for the JVM to look at the available number of cores and just turn on the Parallel Garbage Collector. Do I really have to manually turn it on so that Minecraft will use it? Why can't the JVM allocate more memory on its own? Does it really need permission to use more than 1 Gig of memory? It just sits there waiting for the day some user decides to import every single possible datapoint into it, crashes, having used 1 Gig of 8, with a "Out of Memory" error. It's not like Developers know what the Xmx and Xms setting need to be. They just set them arbitrarily high in hopes that some user doesn't try to find out what the maximum datafile it can take is. That just slows it down and makes it so when the GC finally does fire off it has 10x the amount of trash it should have if the value was set lower. Those options are only useful on internal applications that never get into the hands of everyday users. It's probably a great book for server side development, but it is highlighting a major failing of the JVM.

    1. Re:Too many options by Anonymous Coward · · Score: 2, Interesting

      Really, just set -Xincgc -Xmx# and walk away.

      It does periodic GC with that, not waiting for the crash.

    2. Re:Too many options by medv4380 · · Score: 4, Interesting
      You didn't prove anything except point out yet another option to be set. If that was the best way to set the JVM why isn't that the default. Why is it left up to the user to specify it. Why do users have to figure out how to tweak it so that Minecraft work "optimally" on multicore machines? When you have to figure out this

      java -Xmx1024M -Xms1024M -XX:+UseFastAccessorMethods -XX:+AggressiveOpts -XX:+DisableExplicitGC -XX:+UseAdaptiveGCBoundary -XX:MaxGCPauseMillis=500 -XX:SurvivorRatio=16 -XX:+UseParallelGC -XX:UseSSE=3 -XX:ParallelGCThreads=4 -jar /media/storage/minecraft.jar

      -Xincgc might sound good but then again

      -Xincgc Enable the incremental garbage collector. The incremental garbage collector, which is off by default, will eliminate occasional garbage-collection pauses during program execution. However, it can lead to a roughly 10% decrease in overall GC performance.

    3. Re:Too many options by bws111 · · Score: 1

      The major use of Java is server side enterprise stuff, and all those controls are critical there. It is certainly not a major failing of the JVM, it is an important feature. The alternative to the JVM having all those controls is for each and every application to have its own controls.

    4. Re:Too many options by idontusenumbers · · Score: 2

      Some of these directives may be VM specific and might change the way synchronization or allocation works in such a way that it's inconsistent with the "default" and break applications that weren't tested with these options. Additionally, Java has a tendency to pre-allocate memory when it's not needed in preparation for future allocation. Operating systems will likely show this as "memory in use" even though Java will give up this memory when it detects the OS is running low. Users that aren't aware of this may claim "Java is a memory hog" when really it's just being efficient. Allowing developers to put a cap on this maximum size can help alleviate users complaints as the developer should be able to determine a reasonable maximum amount of memory.

    5. Re:Too many options by devent · · Score: 1

      I think you already answered your own question. There is no "one size fits all" and if you can live with a 10% decrease in overall GC performance, then you can enable -Xincgc and have less GC related pauses. it's just depending on what you want and what your use case is.

      If I understand Performance Options Option and Default Value correctly, then most the options you mentioned are enabled by default already anyway. Except the flags DisableExplicitGC and UseParallelGC, some other you mentioned I didn't found, and ParallelGCThreads is already set to the value for the platform where the JVM is running.

      Some of the performance related options are already enabled by default, and there are some you can set if you know your machine. So I don't really understand your complain.

      --
      http://www.mueller-public.de - My site http://www.anr-institute.com/ - Advanced Natural Research Institute
    6. Re:Too many options by TheSunborn · · Score: 1

      "The JVM really needs to get smarter. 60 different controls and switches is just too much. How hard can it be for the JVM to look at the available number of cores and just turn on the Parallel Garbage Collector. "

      Its easy enough to count cores and enable the parallel collector, but the total cpu usage increases when using the Parallel Garbadge Collector. This mean that if you have a lightly loaded system the Parallel Garbadge Collector is a net gain, but if your system is already running close to 100% at all cores, using Parallel Garbadge Collector will decrease total performance. So the 'correct' setting require system knowledge which java for obvious reasons can't have.

      "Do I really have to manually turn it on so that Minecraft will use it? "

      You should not have to. Minecraft really ought to do it for you, because it can assume that it need maximum performance. This is a Minecraft fail, not a java fail.

      "It just sits there waiting for the day some user decides to import every single possible datapoint into it, crashes, having used 1 Gig of 8, with a "Out of Memory" error. It's not like Developers know what the Xmx and Xms setting need to be. "

      Of cause the developer know. For desktop software Xms should not be set, and Xmx should be 9999G which will cause the software to behave like all other software. If it need memory, it will allocate it :}

      "They just set them arbitrarily high in hopes that some user doesn't try to find out what the maximum datafile it can take is. That just slows it down and makes it so when the GC finally does fire off it has 10x the amount of trash it should have if the value was set lower."

      Most apps should newer set Xms. If you don't set Xms java will allocate a default amount of memory. When that memory have been used it will do a garbadge collect. If may then allocate more memory if there were not much garbadge.

      The only case where anyone should set Xms is if the application know that it will always need that much memory. We set it on our tomcat server, because we know that our app always require atleast 1GB of memory, but it is always safe not to set. Not setting it may cause slight performance drop duing startup, while java scale its memory allocation up.

      "Those options are only useful on internal applications that never get into the hands of everyday users. It's probably a great book for server side development, but it is highlighting a major failing of the JVM."

      I would say it is a major failing of the developer. I mean setting them correct for desktop apps is really easy. Expecting the enduser to set them is stupid.

    7. Re:Too many options by Zaph0dB · · Score: 1

      ...and Xmx should be 9999G...

      Unfortunately, the Sun JVM (now Oracle main JVM) "array cells are consecutive in memory" blocks this. When the JVM reports "free memory = T" it must be able to allocate an array of size T. However, due to the aforementioned feature, this require the JVM to pre-allocate all the memory so it can reshuffle everything to be able to allocate that array in consecutive memory addresses. So why didn't they (Sun, now Oracle) drop this feature? Because it helps tremendously in signal and image processing, allow you to fine-tune memory-based optimizations and, usually, offers better array instantiation speed.

      --
      When in danger or in doubt, run in circles, scream and shout [Robert Heinlein]
  19. tuning performance vs production blows up by roman_mir · · Score: 4, Informative

    In my experience, performance tuning is not something that is given much consideration until a production program blows up and everyone is running around in circles with sirens blaring and red lights flashing.

    - if production blows up it signals that the underlying problem is not likely to be fixed with 'performance tuning'.

    There is performance deficiency and then there is "production blows up" and those are different things and must be addressed by different sets of practices at different times.

    Production blowing up means the design is flawed, it means misunderstanding of how the application was going to be used.

    Slow response time on the other hand is about tuning, but it's very unlikely that environment tuning can help really to fix this.

    Back in 2001 I was working for then Optus that was bought out by Symcor and the main project they brought me to (contract) was for this Worldinsure insurance provider, and the project was to do some weird stuff, business wise speaking, allow clients to compare quotes from different insurance providers. Business model was changing all the time, because insurance providers do not want their products to be compared against one another on line (big surprise).

    The contract was expensive (5million) and WI wouldn't pay the last bit (a million I think) until the application would start responding at a 200 requests per second, and it was doing 20 or so :)

    If anybody thinks that just some VM tuning can fix a problem where application is 10 times slower than expected, well, you haven't done it for long enough to talk about it then.

    It took a month of work (apparently I wrote a comment on it before) that included getting rid of middleware persistence layer, switching to jsp from xslt, reducing session size by a factor of 100, desynchronising some data generators, whatever. Finally it would do 300 requests per second.

    But the point is that when things are crashing or when performance is really a huge issue, you won't be optimising the VM.

    VM optimisation is not generally done because I think the application has to do something that is not generic.

    Imagine an application that only does one thing - say it only reads data from a file and then runs some transformation on it, maybe it's polygon rendering. Well then you know that your app. is doing only ONE THING, then you can probably use VM optimisation, because you can check that the one thing your app does will become faster or more responsive, whatever.

    But if your app includes tons of functionality and tons of libraries that you don't have control over and it runs in some weird container on top of JVM, then what do you think you are going to achieve with this?

    You likely will optimise something very specific and then you'll introduce a strange imbalance in the system that will hit you later and you won't see it coming at all.

    If your app does one thing, maybe you have a distributed cluster with separate instances being responsible for one type of processing, then you probably can use specific optimisation parameters.

    1. Re:tuning performance vs production blows up by Anonymous Coward · · Score: 0

      mod parent up

  20. Re:How much difference do these options really mak by Anonymous Coward · · Score: 0

    -XX:+UseConcMarkSweepGC helps a ton if you need low latency, and have at least 4 cores.

  21. Re:How much difference do these options really mak by naasking · · Score: 1

    And does the numeric value of that option dictate the degree of JIT-time optimization performed?

  22. Here is an idea by Anonymous Coward · · Score: 0

    You could also just use a faster programming language.

    1. Re:Here is an idea by roman_mir · · Score: 2

      I have news for you that may just be too hard to swallow - it is absolutely possible, and it happens all the time, that garbage is written in all sorts of programming languages.

      The actual problem is often found between the chair and the keyboard (or more generically, somewhere in wetware of the people involved, developers, designers, management, etc.)

  23. Re:Futile by Mr+Thinly+Sliced · · Score: 4, Insightful

    Fair points but I'd say there's a few places that Java just doesn't cut it - strict scheduling and / or real time needs. O, and GUI stuff, too.

    So basically, no GUI, no audio, no video. Which only more or less leaves what it currently is king of the hill for - server side business processing.

    I've tried real time and Java, and the jitter that garbage collection introduces (yes, even with parallel garbage collection and all that stuff) makes it hugely unpredictable.

    Strangely enough, the company formerly known as SUN knew this, and tried to create a "real time" flavour of Java with such extensions - but it takes so much effort to port your code (and the JVM is slightly less than brilliant) that you're far better off going to C/C++.

  24. Performance battles of GCed languages. by Anonymous Coward · · Score: 0

    My three favourites languages for programming that include an integrated garbage collector and are on top level of CPU performance are:

    1. 1. ex-Sun's 32-bit JDK 1.3.1 hacked by myself for providing two statements label/goto in this ancient language old Java.
    2. 2. Glasgow Haskell Compiler (GHC 7.5 devel) as in http://www.haskell.org/ghc/dist/current/dist/ghc-7.5.20120214-x86_64-unknown-linux.tar.bz2
    3. 3. The coming OCaml-3.13.0 that will provide its new feature GADT that did exist in GHC.

    Successful stories: Apache's Hadoop over JVM, Plasma compiled by OCaml, Agda type assistant, etc.

    JCPM: and what about slower programming languages? I won't use them much unless stupid code around there (e.g. bash for commands, html for layout, etc).

  25. Re:Futile by K.+S.+Kyosuke · · Score: 3, Insightful

    Or just use the FFI, Java Native Access.

    --
    Ezekiel 23:20
  26. Re:Futile by Ichoran · · Score: 1

    Agreed--you need to use libraries written in C/C++ for audio/video. But you can certainly call them from Java, as long as they handle the streaming side of things on their own. Whether or not it's suitable for GUI work depends on what you want your GUI to look like; if platform integration is your top priority (default widget sets, color schemes, etc.) then no, it doesn't work so well. Otherwise, it's not fantastic but it's servicable (again assuming blistering performance isn't necessary).

  27. Re:lol java weenies by nobodylocalhost · · Score: 1

    Hmmm, what are you talking about? Java is about as much of a scripting language as z80 assembly. When you run JVM, it essentially is an emulator, emulating imaginary hardware. Just like running a z80 processor emulator on your intel/amd/ppc/sparc cpu. Would you call z80 assembly a scripting language? When op talk about relations between JVM and Joe Schmo Code Monkey, what he really meant was "Programming in Java is very different from knowing your hardware and the hardware you are trying to emulate in order to figure out the most efficient way to complete tasks". Albeit Java was never designed to be efficient. The goal was to make a standard portable environment across many processors and operating systems. So performance tuning in one environment may very well be detrimental in another. As such mastery in performance tuning also varies from environment to environment. Someone who's awesome at tuning Java performance on solaris/sparc may totally suck at tuning Java performance on linux/intel. All in all, i think your assessment is oversimplifying and generally ignorant.

    --
    Where is the "Ignorant" mod tag?
  28. Re:How much difference do these options really mak by Anonymous Coward · · Score: 1

    Why do you need to specify heap size at all?
    Every native program can allocate just as much heap as it needs from Virtual Memory, and no more.

  29. Re:Futile by HarrySquatter · · Score: 1

    No for audio/video you need libraries written using SIMD assembly. Anything else is going to be way too slow.

  30. I don't use anything but heap settings by msobkow · · Score: 4, Informative

    I've worked with Java since 1.0. The only optimization options I've ever used were the heap and stack size adjustments.

    Setting your memory heap too high actually degrades performance, oddly enough. I've got 4GB on this box and over 2.5G is normally used by disk cache, but if I allocate more than about 768MB to the heap, the performance suffers.

    Maybe some of these options have real effects on certain production code characteristics, but I've found the best performance tuning options are:

    • Whenever and wherever possible, use intrinsic types, especially extracting a char from a string for evaluation rather than using the object accessors for a String. For whatever perverse reason, the Oracle Java compiler will keep re-fetching the value by re-executing the getChar() rather than realizing it's a constant once the value has first been extracted, because the String isn't changing. Net performance boost for my code: over 30% improvement for a days coding on a multi-year project.
    • Instead of allocating and destroying objects, consider hanging on to used objects and using your own allocator. This won't help for implicit object construction, but reusing modifiable objects helps performance dramatically. I saw about a 10% performance improvement when I experimented with this. Raw object allocation is EXPENSIVE.
    • Wherever possible, tighten your loops into a single statement of execution. For unknown reasons, the JVM seems to perform better calling a small function fragment than it does executing inline code in a for/while loop block. This makes no sense based on what I know of C++ tuning, but there you have it: Java likes functions better than inline code when executing loops. Maybe there is some optimization that kicks in for a function that doesn't happen for a code block.
    • If possible, construct a huge single String assignment using conditional expressions (i.e. ( bool-expr ) ? ret-if-true : ret-if-false ) instead of appending to a string buffer with a sequence of if-then-elses. The code is harder to read, but for anything of moderate complexity you can achieve up to a 30% performance improvement by doing this.

    So there you have it -- my favourite REAL WORLD, TESTED, and PROVEN TO WORK performance tweaks.

    --
    I do not fail; I succeed at finding out what does not work.
    1. Re:I don't use anything but heap settings by Anonymous Coward · · Score: 1

      unfortunately, some of these recommendations may be left over from java 1.0. i'm pretty sure object pooling became a bad idea right around the time that the generational gc became standard. with the generational gc, allocating and discarding short lived objects is dirt cheap. probably cheaper than maintaining your pool. not to mention that object pools have the characteristic of maintaining objects in old gen pools with references to objects in new gen pools, which is exactly what you _don't_ want with a generational gc.

    2. Re:I don't use anything but heap settings by SplashMyBandit · · Score: 1

      Actually, re-using objects is an excellent strategy if you are using JavaBeans (where you have symmetric getters and setters). Unfortunately, so many programmers hide setters away from you, supposedly to protect you from yourself, but it makes it impossible to re-use objects even where it would otherwise not only be perfectly possible and valid but also very efficient as well. In short, use JavaBeans when you need complex (non-intrinsic) value-objects and make the setters symmetric with the getters, *always*. You don't generally need to work pools of objects if you can re-use a JavaBean directly. Immutable objects have their uses, but they are very expensive in many performance-critical situations. If an object doesn't have to be immutable, don't make it so (keep it a Plain Old Java Object [POJO] where you can).

      Although if you do need pooling (and you do from time to time) then Apache Commons Pool has done all the work for you. Real-life example, I worked on an Internet-scale project where the cost of obtaining a java.util.Calendar was too expensive (since it internally gets a timezone) and affected a critical part of very heavily used code. Pooling instances was very helpful in keeping high performance.

      As always with performance you ought to be profiling your code before optimizing. Fortunately the Java SDKs come with JVisualVM which is absolutely fantastic - you don't need to compile a special profiling version of your program (like C or C++) you can simply attach to *any* running Java process and see what it is up to. You can even do this to remote processes (although you get slightly less information than if you hook up to a local process). This is an unbelievably good feature that allows you to optimize your Java sensibly - which should result in code at least as fast as C if you know what you are doing.

      Once you have done your profiling with JVisualVM you can figure out what you need to do next:
      Am I doing a lot of string concatenation (eg. text or XML processing)? then changing one or two Strings to StringBuffers can often give you a factor of 10 speedup in critical code (I've done this myself)
      If you are creating a lot of objects then having a fully mutable JavaBean can help (I've done this with a Matrix class - which saved re-initialising the identity matrix a lot).
      If you are CPU bound then how about splitting your working into multiple threads? Much easier than doing multithreading in C or C++
      Still don't have enough CPU power? cool, you're in Java so move your application from a little Windows box onto a Linux/Unix huge blade server.
      are you multi-threaded but lock contention for shared resources holding you back? then get rid of that fancy shared singleton and use non-shared POJO objects in each thread to hold what would otherwise be shared state.
      Running out of memory and is the GC thrashing? simple, just give your application more memory with the -Xmx JVM parameter.
      Doing a lot of iteration over lists or arrays to find things? then create a java.util.Map to cache lookup data.
      These are all simple fixes that can make Java very fast. JVisualVM will help you make the decision about where to start.

      Of course, the classic paper discussing how fast the JVM had got even 4 years ago from the French supercomputing research arm of INRIA:
      https://blogs.oracle.com/jag/entry/current_state_of_java_for
      If anyone still thinks the JVM is slow then they are out-of-date. As long as your developers are competent you can make Java applications very fast.

    3. Re:I don't use anything but heap settings by dr2chase · · Score: 1

      Problem with object pools (if you are multi-threaded) is that they you need to synchronize access to them, and THAT adds overheads and potential bottlenecks. You can make your pools thread-local, but then you've got to worry about them getting too large (how many threads do you have, also?). Unless you're doing some really expensive object preparation, if you've got a generational collector, that's usually a good bet -- simpler, fast enough, not a source of confusion six months down the road.

    4. Re:I don't use anything but heap settings by SplashMyBandit · · Score: 1

      All good points. You don't even need do use a thread local, just have an independent pool per thread (assuming your threads are long lived and do a lot of work). Simple and is nearly as efficient as having a global pool, but without the locking overhead.

    5. Re:I don't use anything but heap settings by Brian+Feldman · · Score: 1

      If you're building strings, use a sensible API like java.lang.StringBuilder (or if you're feeling unnecessarily anachronistic, java.lang.StringBuffer).

      StringBuilder s = new StringBuilder("whatever");
      s.append(somestuff);
      s.append("someotherstuff");
      return s.toString(); //note: all uses of APIs may be entirely inaccurate

      --
      Brian Fundakowski Feldman
    6. Re:I don't use anything but heap settings by Brian+Feldman · · Score: 1

      In the few instances I've seen a co-worker using object pools, removing them has been a benefit in every single way. Even if the objects do cost a little to construct, so does synchronously maintaining a giant linked list of objects.

      --
      Brian Fundakowski Feldman
    7. Re:I don't use anything but heap settings by msobkow · · Score: 1

      I haven't had to do this with Java yet, but I have implemented thread-specific pools with multi-threaded C++ application code, where each thread had it's own pool. It was a critical performance tweak for one system I worked on 12-15 years ago, as we were pushing the hardware so hard that within a year the IO bus wouldn't be able to move the expected data even if it did nothing but shuffle MY module's data 24x7. (Yes, we EXPECTED to need new hardware, but we needed a solution NOW.)

      Fortunately, Java seems to do some pooling of it's own for Strings and box types -- they perform FAR better than general objects, so they have to be doing something special for their allocation and destruction. In particular, I've found that well written Java string manipulation code actually outperforms my C++ code -- even though the Java code deals with UTF16 data instead of 8-bit ANSI/ASCII data. Or maybe byte manipulation on modern processors just isn't as efficient as it used to be.

      --
      I do not fail; I succeed at finding out what does not work.
    8. Re:I don't use anything but heap settings by msobkow · · Score: 1

      Practical experience and years of testing are why I recommend the ugly looking conditional statements. The Java compiler seems to build one big string buffer with one allocation when you use that technique, rather than repeated calls to StringBuffer.append(). But go ahead, stick with what's easy to read if you're not concerned with raw performance -- readability is every bit as important as performance when it comes time to enhance or maintain the code by hand.

      --
      I do not fail; I succeed at finding out what does not work.
    9. Re:I don't use anything but heap settings by msobkow · · Score: 2

      Who said anything about linked lists? Allocate ARRAYS of objects so one big contiguous chunk of memory can be allocated and allocate from those "pages" of objects, not linked lists.

      Furthermore, no one said anything about using a global object pool. For peak performance, you want a pool per thread so you don't have to incur synchronization overhead.

      But you are correct -- a poorly written object pool will degrade performance, not improve it.

      As to the grandparent post -- just because I started with Java 1.0 doesn't mean I assume that the JVM hasn't changed. I've been redoing my tests with each Java release that came out to see if my old assumptions still applied.

      I'm a professional programmer, not some kid hacking code in a basement.

      --
      I do not fail; I succeed at finding out what does not work.
    10. Re:I don't use anything but heap settings by Anonymous Coward · · Score: 0

      Maximizing mutability is a horrible idea.

      Mutable objects end up being defensively copied. Immutable objects only need to be copied when they change.
      Immutable objects are intrinsically threadsafe.
      Immutable objects can reliably share internal state. String, for example, does exactly this.
      Mutable objects generally need to allow invalid states. Immutable objects can verify their invariants at construction to ensure that no instance is ever invalid.

      Josh Bloch's book, Effective Java, has an excellent section on this (Item 15). There are a number of other good articles that explain why mutability results in less reliable code and is not always a performance win.

    11. Re:I don't use anything but heap settings by dkf · · Score: 1

      Getting good performance in Java really requires knowing about StringBuilder (unless you're not doing anything much at all with strings). That's because the compiler changes this:

      s += "the quick " + "brown " + fox + " jumps " + over;

      Into this:

      s = new StringBuilder(s).append("the quick brown ").append(fox)
      .append(" jumps ").append(over).toString();

      The adjacent constants are combined into one, and the variable parts are done as separate calls to append(). (The old-style StringBuffer has the same interface, but with added locking for if you want to use it in multiple threads at once or make things run slower for no good reason.) This matters because if you're building up a string in a loop — a very very common thing I find — then you're better off putting the creation of a StringBuilder before the loop and the reconversion to string afterwards. This helps hugely because StringBuilder uses an amortized-constant-time string growth strategy so those appends are pretty cheap (the loop will be of linear cost), whereas if you're converting back and forth to a string you've killed that and turned the loop into quadratic cost (plus all those object allocation costs too). With nested loops, the cost goes up of course.

      The long and short of it is this: if your Java program is slow, check for problems in string construction. They're easy to fix and even vaguely intelligent use of StringBuilder will speed things up.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    12. Re:I don't use anything but heap settings by dr2chase · · Score: 1

      Most likely it uses its own allocation pools for all objects, and may include some localization for non-escaping objects. It is possible that it could spot objects whose interfaces are side-effect free and that are never tested for object equality; those are effectively "values" and subject to loop-hoisting and common-subexpression optimizations.

    13. Re:I don't use anything but heap settings by Raenex · · Score: 1

      As to the grandparent post -- just because I started with Java 1.0 doesn't mean I assume that the JVM hasn't changed. I've been redoing my tests with each Java release that came out to see if my old assumptions still applied.

      I'm a professional programmer, not some kid hacking code in a basement.

      I expect a professional Java programmer to know that "Raw object allocation is EXPENSIVE" is WRONG and OLD information: http://www.ibm.com/developerworks/java/library/j-jtp01274/index.html

      "Performance advice often has a short shelf life; while it was once true that allocation was expensive, it is now no longer the case. In fact, it is downright cheap, and with a few very compute-intensive exceptions, performance considerations are generally no longer a good reason to avoid allocation. Sun estimates allocation costs at approximately ten machine instructions. That's pretty much free -- certainly no reason to complicate the structure of your program or incur additional maintenance risks for the sake of eliminating a few object creations.

      Of course, allocation is only half the story -- most objects that are allocated are eventually garbage collected, which also has costs. But there's good news there, too. The vast majority of objects in most Java applications become garbage before the next collection. The cost of a minor garbage collection is proportional to the number of live objects in the young generation, not the number of objects allocated since the last collection. Because so few young generation objects survive to the next collection, the amortized cost of collection per allocation is fairly small (and can be made even smaller by simply increasing the heap size, subject to the availability of enough memory)."

      There are cases where it makes sense to use your own allocator, generally for big objects, but the blanket advice you gave will cause more harm than good.

  31. If you want performance by freeshoes · · Score: 1

    The more you abstract what's underneath the less performance you can achieve. Assembly vs C, C vs Java/C#/Python, Running code on a host vs a guest virtual machine, I think you get the point.

    1. Re:If you want performance by Anonymous Coward · · Score: 0

      [Citation needed]

      C is actually quite hard for compilers to optimize because it's hard to make assumptions about which code interacts with what data. A more abstract language allows a compiler to make more assumptions, which can allow it to optimize more aggressively. When using JIT, a more abstract language may very well end up with better performance.

      Of course in theory there is nothing you can do in C, Java, C#, and Python that can't be done in assembly, but the latter is quite prone to error and tends to take much, much longer than using a more abstract language. But once you more beyond assembly to C, you start relying on the optimizer of the compiler and when it comes to optimizers there is no reason to assume a less abstract language is somehow superior to one that is more abstract.

  32. Java PERFORMANCE? by atari2600a · · Score: 0, Troll

    Sounds like an oxymoron to me...

    1. Re:Java PERFORMANCE? by Anonymous Coward · · Score: 0

      Sounds like an oxymoron to me...

      Sounds like a moron to me...

  33. Re:How much difference do these options really mak by medv4380 · · Score: 2

    You have a point, and the answer isn't any good ether. You specify the Heap size so that the Garbage Collector can be lazy and not clean up memory until the specified heap is at a certain level. I think it's just a Java thing. C# and .net grow as needed up to the systems limit. GoLang even though native is Garbage Collected (sorta) and I've yet to find some arbitrary default if one exists. Java only wants to use 1/4th or less of the available system memory, and I can only think of reasons linked to Garbage Collection.

  34. Re:Futile by Brian+Feldman · · Score: 4, Insightful

    Oh, please, neither Java nor C++ is superior to the other. They both have strengths at certain kinds of programming but altogether support extremely similar semantics in most areas. There are very difficult-to-use portions of both Java and C++. You should get yourself some more experience.

    --
    Brian Fundakowski Feldman
  35. Java is an oxymoronic toxic toy. by Anonymous Coward · · Score: 0

    The Java's performance is worse due to many factors:

    1. 1. It's using <genericity> instead of <templating>.
    2. 2. Its <genericity> is limited to only non-primitive objects (e.g., you can't instantiate primitive types as boolean, int, long, float, double, etc).
    3. 3. It doesn't use the feature GADT as used in Glasgow Haskell Compiler and in the coming OCaml 3.13.0 that uses a most powerful type inference system known until the actuality.
    4. 4. Every objects are references to objects, not as expanded/aggregate types as in Eiffel.
    5. 5. It always did lack the most powerful CPU-performance Partial Evaluation as used in Psyco, PyPy, etc.
    6. 6. And didn't provide Ahead-Of-Time (AOT) for faster boot or reboot of the application.
    7. 7. It didn't provide my two essential statements label <label>: and goto <label>;.
    8. 8. And it's not multi-architecture yet (their supports to ARMv7, ARMv8, MIPS, Alpha, etc. are not available yet to the public).

    JCPM: Java is still a toy, a baby of >10 years of unsustainable growning, and it's not adult yet.

    1. Re:Java is an oxymoronic toxic toy. by SplashMyBandit · · Score: 1

      Interesting you know about odd, unpopular languages like Haskell but don't even know about GCJ, which would address your issue (6). The Oracle JVM is not the only JVM in existence. Plus, apart from start-up time (inconsequential on servers) the JIT generally produces faster code than AOT since superior optimisation information is available to a JIT instead of a AOT compiler. Even on the desktop these days were the JVM is pre-loaded by the OS the start-up time is not that long, and becomes increasingly insignificant as you move away from small programs to large programs (hell, MS Word takes forever to load on a clean reboot and that it written in C++).

      As for (2). You don't need to have a generic instance of a primitive type. The JVM is smart enough to 'autobox' this for you (a nice feature Java stole from C#) with the resulting effect that you essentially get the generic class using primitive type and the resulting performance gain. Nice to have such things happen under the hood.

      Strange you also would like to use goto. Even in 1968 Dijkstra considered this harmful in a famous paper - so generally anyone wanting to use this is considered slightly deranged, there are alternatives that are much more maintanable. So railing against Java for a construct that the consensus considers bad form could also be seen as bad form (or an unawareness of just how bad designs that need goto are).

      Also, Java does provide labeled statements, and goto is reserved but not used. You can use the label to continue in a loop with a similar effect to goto - although as a said before, this is not encouraged by the consensus since usually the use of such a construct is considered 'harmful' to good development practices.

      It's kinda amusing that you cherry pick the best features from a slew of languages and indicate that Java can't hold it's own against half-a-dozen languages at once, yet each of those languages blow when compared to Java one-on-one. That's pretty typical for the kind of academic language snobbery you get around here. When you start building *huge* systems you realise that the 'toy' languages you mention aren't really that good for developing in the large - plus they are good for specific problems and aren't really that well suited as a general purpose solutions that you are going to invest significant financial and developmental resources into (that is, build a business with many collaborating people that simply can't chose a new language du jour for their clients). The strengths of those alternative languages (and they have some for sure) become their weaknesses when solving the problems of scale and development continuity in the real world (that is, some of the nifty languages features actual hinder *getting real things done* - which is what really matters).

    2. Re:Java is an oxymoronic toxic toy. by Anonymous Coward · · Score: 0

      Briefly, the Oracle JVM is still almost frozen since that it was founded and although newer technologies were discovered but not added to this 'frozen' sw-engine, as by example, GADT type inference system, Partial Specialization, Supercompilation, etc.

      JCPM: the company maintaining 'frozen' this thing for a dozen of years (instead of expanding the potential of this thing) is equal to DYING its involved MASSIVE communities into a kind of 'frozen' stucken-fake technology.

    3. Re:Java is an oxymoronic toxic toy. by Lawrence_Bird · · Score: 0

      Strange you also would like to use goto. Even in 1968 Dijkstra considered this harmful in a famous paper - so generally anyone wanting to use this is considered slightly deranged, there are alternatives that are much more maintanable. So railing against Java for a construct that the consensus considers bad form could also be seen as bad form (or an unawareness of just how bad designs that need goto are).

      Clearly a member of the NannyState of programming. Will offer you a healthy alternative to that nasty goto/label that your mommy packed you for work today.

    4. Re:Java is an oxymoronic toxic toy. by SplashMyBandit · · Score: 1

      Bah. The kind of reply I get when you've never had to review the work of a dozen lesser programmers to see what simple thing they didn't get right. More complexity is not better - it's a shame if you haven't grokked that.

    5. Re:Java is an oxymoronic toxic toy. by Daniel+Phillips · · Score: 1

      Interesting you know about odd, unpopular languages like Haskell but don't even know about GCJ...

      I like GCJ a lot and I think every Java programmer should use it in preference to the clunky interpreter/JIT combination, absent a compelling reason otherwise. Just for starters, you get real executables.

      --
      Have you got your LWN subscription yet?
    6. Re:Java is an oxymoronic toxic toy. by dkf · · Score: 1

      It didn't provide my two essential statements label <label>: and goto <label>;.

      What high-level structured-programming concept is missing such that you need those low-level primitives?

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    7. Re:Java is an oxymoronic toxic toy. by dkf · · Score: 1

      Strange you also would like to use goto. Even in 1968 Dijkstra considered this harmful in a famous paper - so generally anyone wanting to use this is considered slightly deranged, there are alternatives that are much more maintanable. So railing against Java for a construct that the consensus considers bad form could also be seen as bad form (or an unawareness of just how bad designs that need goto are).

      Actually, what Dijkstra was railing against in that paper (I'll assume you've also read Knuth's response to it) was the tendency of some developers to use goto to create patterns that didn't match what we now call structured programming. Of course, what has happened since then is that the set of structured idioms has expanded (notably including exceptions and try-with-resources) so that there is far less need for a raw goto. The main thing that isn't handled particularly well as yet is a state machine (though you can hack it with a switch in a loop). But if there's some pattern that still needs a direct goto, it should be characterized so that a higher-level pattern can be created.

      At the low level it's all gotos, but they're generated by software so Dijkstra wouldn't have minded them at all.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    8. Re:Java is an oxymoronic toxic toy. by Anonymous Coward · · Score: 0

      The point isn't that you can do it with a high level construct... it's that a simple: "goto" statement can lead to MUCH clearer and easier to read code.

    9. Re:Java is an oxymoronic toxic toy. by Lawrence_Bird · · Score: 1

      Bah. The kind of reply I get when you've never had to review the work of a dozen lesser programmers to see what simple thing they didn't get right. More complexity is not better - it's a shame if you haven't grokked that.

      I was only half jesting but you have clearly proven my point in your reference to 'lesser programmers'. Do you make them bow down before you each morning? Kiss you feet before going to their cube? I have no doubt that you are a strong believer and advocate for the Nanny State - regardless of its target (in this case programming.)

    10. Re:Java is an oxymoronic toxic toy. by SplashMyBandit · · Score: 1

      I think you have the wrong end of the stick and are projecting a worldview onto my statements. Please let me explain. By lesser programmers I mean the non-craftsmen who are just there to collect their paycheck and do the minimum thinking to get through the day. Surely you've had to work with or direct these people. There is nothing wrong with them or their attitude, it's just they are not going to spend a lot of effort worrying about the best, most robust, or most efficient way to solve something. Yet these warm bodies are required to be productive because without them there simply would not be the manpower to *deliver large working systems*. So my statement was not meant to put them down, just recognise the realities of software development on an (post-)industrial scale, and that development processes should select tools that consider them too (hence, part of my promotion of Java's simplicity as a feature).

      So, if we can drop the (unintentional?) ad-hominem on me and get back to the original premise. I believe Java has advantage in its simplicity. Sure, we could solve problems in any number of languages but why not choose one that is general purpose (works well enough no matter whether you are doing embedded, desktop, web, mobile, or supercomputing), can be grasped by teams of 9am-to-5pm workers, has a huge ecosystem, has multi-vendor support (including the all-important Free Software community through GCJ and OpenJDK), has sufficient critical mass that it is not going away in the next decade or two (#1 popularity according to Tiobe - not that this is a beauty contest), will work on all platforms you develop for (except for those specifically locked-out by the manufacturer for business reasons rather than technical ones), yada yada.

      Sure, Java is not always the best fit for some particular aspect of programming that excites those who collect programming languages like butterflies. For me, my ego is not tied up in making things complex, there are far more interesting problems to *actually solve and deliver* than explore the merits of one language construct over another. This is why I make the case for Java, and why I feel it is necessary to counter the strutting of the language snobs (who can give a breadth of language constructs but actually don't deliver large systems that *actually do things*). I hope that explains my motivation a little better - and enables those who are considering Java to get a balanced view on why it is currently so popular and why what some would consider weaknesses (designers deliberately eschew complex constructs) are actually strengths (able for average developers to be productive and deliver working systems).

    11. Re:Java is an oxymoronic toxic toy. by Anonymous Coward · · Score: 0

      This. Say I want to clean up a bunch of resources that are scoped at a function level. In C# or C++, or any other language with "goto", I can "goto cleanup" and be done with it.

      On the Java side, the only way I've found to hack around it is do { ... } while (false); and then break out.

      It's the same result, but readability suffers.

  36. Re:How much difference do these options really mak by SplashMyBandit · · Score: 3, Interesting

    Bugger. I had modded a bunch of posts on this thread and now have to chuck them away just to counter your ignorance (lest your incorrect assumption spread to others). It's cool you are taking a stab at why Java might limit memory, but unfortunately that guess is not correct - so I hope to set yourself (and any other readers) straight on why Java has this feature (if you don't understand the feature you'll see it as a limitation, when in fact it is very important for security).

    The limit Java imposes on memory is to ensure that critical resources (memory) is preserved for the system - and gives the Java user a way to limit what any application can do. This is a very important protection if you followed Java's internet model where Applets (or these days, WebStart applications) and allow remote applications to run. System administrators can also partition what any application can do, in case one is rogue (they can't trust those damn application developers, like me) and uses up all the system memory shared between many applications when running on Big Iron. I don't know whether any remote running .NET applications have this protection and would be interested to hear if they do - if they don't then that means any .NET application could in theory bring your server (and all the other important services you have running on it) to a crawl (as it swaps memory) or possibly even crash through memory exhaustion.

  37. Re:60 options? by Anonymous Coward · · Score: 0

    Cool story bro

  38. Re:Futile by viperidaenz · · Score: 1

    direct buffers work in windows. you just need enough contiguous memory space available to allocate the buffer to.

  39. Re:Futile by viperidaenz · · Score: 1

    So basically, no GUI, no audio, no video.

    That's why Vuze doesn't have an integrated video player or a native, cross platform GUI.

  40. Re:Futile by Mr+Thinly+Sliced · · Score: 1

    That's why Vuze doesn't have an integrated video player or a native, cross platform GUI.

    Given Vuze does have (kinda) those things, I assume you're advocating that Java does?

    I'd hardly say using third party toolkits and/or native blobs written in another language (for both of those you mention) adds weight to the strengths of Java....

    In fact, it confirms what I said - you don't do those things in Java.

  41. 600 pages? by Anonymous Coward · · Score: 0

    The standard Oracle JVM has about sixty 'developer' (-XX) options which are directly related to performance monitoring or tuning... This dense, 600-page book

    600 pages to explain 60 compiler options? That's why I really hate Java.

  42. Re:Futile by bws111 · · Score: 2

    The switches and controls described are run-time options, not code optimizations. They are more like the 'economy or performance' transmission setting. Sometimes you want to get the best MPG and don't particularly care how fast you accelerate. Other times you want quick acceleration, and are willing to let mileage suffer. Having a control means you don't have to re-build your car every time you want a change.

    These options are the same kinds of things. If you only have one application running on a box you may as well let the JVM grab as much of the physical memory as it can, so it does as little garbage collecting as possible. If you add more applications you may want to dial back the memory usage and take a performance hit for that application so other more important apps run better.

    Can you do the same things with C or C++? Of course, as long as each and every application provides its own controls, coded into the applications, for doing that.

  43. Re:Futile by Anonymous Coward · · Score: 0

    Microsoft Works
    Military Intelligence
    Java Performance

  44. Re:Futile by gweihir · · Score: 2

    If you do not have a performance issue, that is fine. Personally, Prototype in Python and port time-critical parts to C. (Object-oriented C, as far as it makes sense.)

    What I do not like about Java is that it is neither a really modern language like Python, nor a really fast and memory-efficient language like C. It is sort of a jack-of-all trades and good at none. It is also a master of syntactic clutter and complex, long code. Still, if you really know what you are doing, you can write good Java code.

    As to the worker-thread pool, if you stay within the limits of the VM, it is admittedly easy to do something like that in Java. But as soon as you go beyond the not very impressive capabilities of the typical Java VM, you are screwed. But my guess would be you know that are are staying within these limits. So, yes, if you know what you are doing, even porting C to Java can make sense.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  45. Re:Futile by gweihir · · Score: 1

    That is nonsense. As long as you get good scheduling responsiveness, C is entirely fine. The problem with Java is not even the language itself (slow as it may be), but the garbage collection.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  46. Re:How much difference do these options really mak by Bill,+Shooter+of+Bul · · Score: 1

    Double Bugger. I was going to mod you up, but you're sort of missing a piece of the puzzle. Java is supposed to be Write once run anywhere. So, yes a decent operating system should be able to enforce memory limits of applications so they don't bring your server to a crawl, but that's not built into Java, so they had to do it by default with the stupid limitation on all programs.

    --
    Well.. maybe. Or Maybe not. But Definitely not sort of.
  47. Re:Futile by gweihir · · Score: 1

    I must have misread the article. 600 pages to describe VM parameters? How insane is that! Java is turning into a more and more complex mess all the time.

    --
    Most ACs are not even worth the keystrokes to insult them. Be generically insulted by this and ignored otherwise.
  48. Re:Futile by bws111 · · Score: 4, Informative

    More like you didn't read it at all. Right in the summary it says: This dense, 600-page book will not only explain these developer options and the underlying JVM technology, but discusses performance, profiling, benchmarking and related tools in surprising breadth and detail.

  49. Re:Futile by Anonymous Coward · · Score: 0

    The C Programming Language is just 228 pages. It explains the entire language.

    This book is 600 pages. It explains the 60 possible command line options for the JVM.

    Java: Enterprisey.

  50. Re:Futile by farble1670 · · Score: 0

    Optimizing Java is sort-of like optimizing a low-powered family car: It does not make a lot of sense. If you really need performance, go to C

    probably true on the client, but not servers. every heard of JIT?
    http://en.wikipedia.org/wiki/Just-in-time_compilation

  51. Re:How much difference do these options really mak by robot_love · · Score: 1

    -XX11 is useful as its +1 faster than -XX10, should be the default really.

    I hear they're contemplating a "-XX12" option that threatens to rip asunder the very fabric of time and space.

    --
    .there is enough of everything for everyone.
  52. Re:Futile by viperidaenz · · Score: 2

    SWT is quite a popular Java library written by one of the JVM vendors. Java is the only platform I know that has libaries to write a GUI that runs on Windows, Mac, Linux, Firefox, Chrome, Opera and Internet Explorer

  53. Re:Futile by bws111 · · Score: 1

    Are you really that dense? It describes the command line options (which would have to be written into your own application if you wanted to have that level of tuning in C). It describes the technology of the JVM (so add some books describing processors and OS internals to your list). It describes performance, profiling, benchmarking, and the tools used to do those things (add a few dozen more books to your list).

    Now obviously C is much easier to do those things with. That is why the first tool for analyzing C memory usage (ThreadSpotter) takes a 149 page book to describe it. So your C library is already up to 377 pages, and you haven't even touched on the technology issues. And of course any documentation on how to tune your application must be written by you.

  54. Re:How much difference do these options really mak by SplashMyBandit · · Score: 1

    Please elaborate how this affects the "Write once run anywhere". I'm afraid I don't quite get what you mean. Thanks.

  55. Re:lol java weenies by Brian+Feldman · · Score: 1

    Actually, a modern Java Virtual Machine and JavaScript Virtual Machine are far more similar than they are different.

    --
    Brian Fundakowski Feldman
  56. Re:Futile by smellotron · · Score: 3, Insightful

    ...the jitter that garbage collection introduces makes it hugely unpredictable... you're far better off going to C/C++.

    Unfortunately, when you really get down to it you will have similar problems in C or C++. You cannot allocate memory from the system heap (malloc or operator new) in the critical path of real-time code. That means everything is preallocated. That means you could have been using Java anyways, with GC disabled. There may be other reasons to use C or C++ for these systems, but the nondeterminism of dynamic memory allocation really applies across the board. It just hits Java users earlier.

  57. Re:Futile by smellotron · · Score: 1

    As long as you get good scheduling responsiveness, C is entirely fine.

    Yes; GCC and ICC are quite good at optimizing SSE intrinsics, to the point that hand-coded asm can be largely avoided. I have heard otherwise for Visual Studio; fortunately, Intel's compiler works on Windows as well. As to the rest of the code, well... just keep an eye on the assembler output from every. single. build.

  58. Re:How much difference do these options really mak by bws111 · · Score: 2

    The book is discussing run-time tuning, so 'write once run anywhere' does not enter into it.

    It seems that a lot of people on here don't 'get' run-time tuning, or they don't think it is important. In the environment that these parameters would normally be used (enterprise software), tuning is critical. All enterprise middleware and most applications have tons of tuning. In an enterprise environment you do want the ability to trade off memory usage for processor usage, for instance. You want to control how much memory is being used. You want to control how many cores your application can use. And those things change depending on lots of variables. For example, at different points during the year different applications may have higher or lower priorities. Workload can be added to or removed from an image, requiring rebalancing of resources. You may find that scaling an application up or down requires different handing of garbage collection.

    Now, all these things can be done (and must be done in an enterprise) regardless of language. If you don't have a tunable run-time then the other option is that every application builds in it's own tuning parameters.

  59. Why fiddle, just re-implement the damn thing by saboosh · · Score: 2, Informative

    An issue recently came up on my Engineering team where a pig mapreduce job that stores in hbase slowed over the course of completing tasks until all the tasks failed due to timeouts. What appeared to be happening was a gc failure and pause due to tenure region exaustion and the built in cluster function to kill off the garbage collecting regionserver. The link below describes the issue and possible workarounds by implementing a custom memory allocation strategy. It's also a must read for anyone who isn't a java garbage collection expert. http://www.cloudera.com/blog/2011/02/avoiding-full-gcs-in-hbase-with-memstore-local-allocation-buffers-part-1/

  60. Re:Futile by Anonymous Coward · · Score: 1

    Java is an OOP butter knife that does it's very best to obfuscate hardware requirements.
    C++ is the swiss army knife equivalent that requires full hardware awareness and customization when applicable, boost and TR2 when not.

    If you're a code monkey, enjoy Java, Struts, Spring, and Swing, but optimizing for performance is like breaking down the foundation of the language.

  61. Re:Futile by Daniel+Phillips · · Score: 0, Flamebait

    Wow, I'm surprised at the driveby downmods in this thread. I mean, I held this image of Java developers as open minded individuals, but maybe there is a significant minority that just aren't. Guys: it is a fact. If you need your program to go fast, plus be OOP, then you should write it in C++. GCC will hand you somewhere between 10% and 200% speedup "for free" on real life algorithms, plus startup time normally faster by a multiple, and a fraction of the memory footprint. And small binaries, and runtime support always installed by default.

    Java has its uses. It is generally faster to develop in and less tricky for the naive programmer. You can effectively build a project faster with less skilled and less expensive, more freely available developers. That is a big deal, not to be underestimated. But if your functional requirements include fast and tight, Java is not the right choice. Well, it's faster than Python or Bash. And sometimes not even that if you include JIT time.

    --
    Have you got your LWN subscription yet?
  62. Re:Futile by Daniel+Phillips · · Score: 1

    (Object-oriented C, as far as it makes sense.)

    It never does, trust me. If what you need is object-oriented C, use C++.

    --
    Have you got your LWN subscription yet?
  63. Re:Futile by Daniel+Phillips · · Score: 1

    Only if you absolutely must get as much out of your hardware as physically possible should you start using C/C++...

    Disagree. You should choose C++ if the speedup will be *noticeable*, not just if you need to squeeze out every last erg of CPU power. In many cases the difference between Java and C++ performance, especially startup time, can be huge. Don't even think about writing light little utilities in Java.

    --
    Have you got your LWN subscription yet?
  64. Re:Futile by Daniel+Phillips · · Score: 3, Insightful

    Woah, browsers! Nice one, in that way you let out QT, which only runs on Window, Mac and Linux. And blows SWT out of the water in every way.

    --
    Have you got your LWN subscription yet?
  65. Re:Futile by Daniel+Phillips · · Score: 1

    Optimizing Java is sort-of like optimizing a low-powered family car: It does not make a lot of sense. If you really need performance, go to C

    probably true on the client, but not servers. every heard of JIT?

    Also true on servers, even with the JIT.

    --
    Have you got your LWN subscription yet?
  66. Re:Futile by dkf · · Score: 1

    In many cases the difference between Java and C++ performance, especially startup time, can be huge.

    Quite apart from the fact that there are applications where startup time really isn't very important, it's important to emphasize that it is possible to write bad code in any language. It's certainly possible to do bad code in both Java and C++. It should be possible for the best of C++ code to beat the best of Java code, but it will be quite difficult to reach that level with either language (both are quite subtle in places) and good code in either will beat bad code in either. (Choosing a good algorithm is still important, folks!)

    The weird thing is that I've found some utilities definitely written in Java still start up very quickly; there's obviously some costs there that most apps are paying which they shouldn't be.

    --
    "Little does he know, but there is no 'I' in 'Idiot'!"
  67. Re:Futile by rve · · Score: 3, Insightful

    Maybe you could use JNI for that, in certain very specialized cases, but if you write parts of your application in C/JNI you run the risk of just combining Java's weaknesses (memory, performance) with C's weaknesses (error prone). A nullpointer in a native code part of your application will unceremoniously crash your JVM and everything running in it.

    JNI is often used for things that can only be done in native code. An example I can think of are atomic compare and swap operations in the java.util.concurrent package. These are implemented via a JNI method essentially calling just one machine instruction (on Intel, it may be a hand full on some architectures). Yes, this is for performance reasons - an atomic compare&swap is faster that using locks, not because native code runs faster but because it's the only efficient way to implement it.

  68. java and performance in the same sentence.. by Anonymous Coward · · Score: 0

    whenever I see java and performance in the same sentence the only words that belongs in between them is "has no" as in:

    java "has no" performance

  69. Re:Futile by Anonymous Coward · · Score: 0

    Imho the best test for a language (implementation) is whether it is possible to implement the language in itself. Would it be possible to write a JVM in Java alone? Then back to the drawing board.

  70. Re:Futile by Anonymous Coward · · Score: 0

    How come you geeks can memorize mountains of trivia and argue the most subtle and arcane points about that trivia, yet none of you understands the apostrophe? It's one of the smallest punctuation marks and is dead easy to understand, yet it utterly defeats all of you.

  71. Re:Futile by Mr+Thinly+Sliced · · Score: 1

    Unfortunately, when you really get down to it you will have similar problems in C or C++.

    Not quite - I do realtime audio processing and when you get down to millisecond / submillisecond timing issues, you simply can't do this in standard Java - even when using a no-allocation loop (as you mention). I know, I've tried apples to apples.

    You can go down the route of using the special realtime JVM as I mentioned above, but then you get other problems (you're not really writing Java, you can't use any of the standard libraries etc).

    I prototype my audio stuff in Java, simply because writing and debugging the DSP code is so much easier with good tools, but the bare metal implementation is C++.

  72. Re:Futile by Cesare+Ferrari · · Score: 1

    Not my experience. I'm continually impressed with how fast java and C# are, and how well systems written in these languages perform in realtime apps. Sure, you get outliers, but then you get outliers from the OS, core swaps, networking stacks, etc etc, it's just one more area you have to watch and carefully consider, that's all. I'm not suggesting that code which hasn't been thought about performs well in this environment, but that it's possible to produce perfectly functional realtime systems with these languages.

  73. Re:Futile by Mr+Thinly+Sliced · · Score: 1

    I'm not saying it's not fast, I'm saying that tight timing related things (like nano sleeps to wait until the soundcard buffers are ready to be filled again) have too much jitter to be useful.

    I can happily get 10 ms audio latency in Java, but going any lower is where it just doesn't cut it. Letting the thread busy wait isn't really an option when the machine has to be doing other things at lower priority too.

    In short, using Java's nanosleep with tight timing tolerances seems to randomly get wakeup jitter when the VM chooses to do some internal stuff. This is with a no-allocation loop confirmed with tracing tools.

    My best guess from profiling the system calls is that Java is doing some mutex related things that's causing the jitter. I neither have the time nor inclination to "fix" this problem, as the solution is quite simple. Write it in a language where I have control over it.

    Don't forget, fast != predictable and that's where C/C++ earns its paycheck.

  74. Re:Futile by Daniel+Phillips · · Score: 1

    Quite apart from the fact that there are applications where startup time really isn't very important...

    Funny, why is it that I don't know any of those applications?

    It is not only quite possible for C++ code to beat Java in performance, startup time and memory footprint, it is quite easy.

    Could you please give me an example of a utility written in Java, and I will measure its startup time. Thanks.

    --
    Have you got your LWN subscription yet?
  75. Re:Futile by Daniel+Phillips · · Score: 1

    Wow, I'm surprised at the driveby downmods in this thread. I mean, I held this image of Java developers as open minded individuals, but maybe there is a significant minority that just aren't. Guys: it is a fact. If you need your program to go fast, plus be OOP, then you should write it in C++. GCC will hand you somewhere between 10% and 200% speedup "for free" on real life algorithms, plus startup time normally faster by a multiple, and a fraction of the memory footprint. And small binaries, and runtime support always installed by default.

    Java has its uses. It is generally faster to develop in and less tricky for the naive programmer. You can effectively build a project faster with less skilled and less expensive, more freely available developers. That is a big deal, not to be underestimated. But if your functional requirements include fast and tight, Java is not the right choice. Well, it's faster than Python or Bash. And sometimes not even that if you include JIT time.

    OK, what is it about Java programmers and not being able to tolerate factual statements about their favorite language?

    --
    Have you got your LWN subscription yet?
  76. Re:Futile by rve · · Score: 1

    foreigners, non native speakers

  77. Re:Futile by viperidaenz · · Score: 1

    Except you can't use your QT code in both a thick client and a web client.

  78. Re:lol java weenies by Anonymous Coward · · Score: 0

    Dumbass: java scripters do not write javascript.

  79. Re:Futile by LizardKing · · Score: 1

    It is not only quite possible for C++ code to beat Java in performance, startup time and memory footprint, it is quite easy.

    Yup, the startup may be quicker with an app written in C++, bit all too often it's followed by a catastrophic crash.

  80. Re:Futile by Daniel+Phillips · · Score: 1

    It is not only quite possible for C++ code to beat Java in performance, startup time and memory footprint, it is quite easy.

    Yup, the startup may be quicker with an app written in C++, bit all too often it's followed by a catastrophic crash.

    So... why haven't I seen any of those catastrophic crashes you talk of in as long as I can reasonably remember? Oh wait, right, Chrome used to go "snap" and Firefox would oom once a week. Gosh.

    --
    Have you got your LWN subscription yet?
  81. Hmm...revolutionary idea here ... by Anonymous Coward · · Score: 0

    ditch the book - use "new" and "delete" to allocate and free memory ; could be a whole new paradigm!

  82. Re:Futile by Anonymous Coward · · Score: 0

    it's and its are not easy to understand, since a rule is broken.

    Struts's vs. struts' is not easy to understand, since they are edge/corner cases.

    Hallowe'en is not easy to understand because it is archaic.

  83. Re:Futile by Anonymous Coward · · Score: 0

    > It never does, trust me. If what you need is object-oriented C, use C++.

    Don't get stupid. There's no reason to use a complex language with ultra-long compile-times and tons of inline code if you can just as well use C. Especially in the context of Python extensions or interfacing with other C code, using C++ is not a good option, as you have to make sure to stay C compatible and not leak exceptions to the C code calling you.

  84. Re:lol java weenies by Anonymous Coward · · Score: 1

    IIRC, Java VMs work on bytecode whereas JavaScript VM's usually work on ASTs.

  85. Re:How much difference do these options really mak by medv4380 · · Score: 1

    That particular reason would only apply to applets where the default is set to 64megs. The first and primary reason to go in and change the memory allocation is to decrease Garbage Collections. If Eden is TOO big your garbage collections take TOO long, but if your Eden is TOO small your garbage collections are TOO frequent. Only a lazy and arrogant system admins would think that the memory settings were for them to enforce some form of system policy.

  86. Re:How much difference do these options really mak by SplashMyBandit · · Score: 1

    Sysadmins don't do it for 'policy' - they do it for performance and server safety.

  87. Re:How much difference do these options really mak by Bill,+Shooter+of+Bul · · Score: 1

    Ok, I wasn't specifically talking about the context of the book, but rather the rationale behind the run time options. Their "write once, run anywhere" philosophy extends beyond the actual writing of the code to the run time tuning parameters. Comprendes?

    --
    Well.. maybe. Or Maybe not. But Definitely not sort of.
  88. Re:How much difference do these options really mak by Bill,+Shooter+of+Bul · · Score: 1

    With the memory limitation built in, you can easily port your application to a server of completely different architecture that lacks the memory limitation feature. I don't see why that's so hard to understand, but apparently two of you do.

    --
    Well.. maybe. Or Maybe not. But Definitely not sort of.
  89. Re:How much difference do these options really mak by bws111 · · Score: 1

    No, you are entirely wrong. Please show us any document that states what you said. "Write once, run anywhere" means exactly what it says. The developer does things once, and the user runs it in whatever environment they want. How does a user specifying different tuning parameters when he starts his JVM affect what the developer did? The application was still written (and compiled) once. And the application will run, unchanged, no matter what the users priorities are with regards to things like heap sizes, GC techniques, etc. That is pretty much the very essence of "write once, run anywhere".

  90. Re:Futile by kaffiene · · Score: 1

    " it's faster than Python or Bash. And sometimes not even that if you include JIT time."

    TROLL.

  91. Another shortcoming by rwreed · · Score: 1

    I just started reading this book, based on the review, and it looks like it'll be worthwhile.

    However, in the first chapter, in the section titled Choosing the Right Platform and Evaluating a System (which really just focuses on how the newer Sun Sparc processors differ from other multi-core, multi-threaded processors), they manage to repeat themselves four or five times, using almost the same words each time.

    I'm hopeful that this is an isolated case and not something that happens throughout the book. The earlier parts of that first chapter didn't have the same issue.

  92. Re:Futile by SomeStupidNickName12 · · Score: 1

    Stop thinking that everything is a utility, 90% of Java "applications" are not client side applications but run server side and where if it takes 5seconds or 30seconds to startup its irrelevant.

    When you start hitting heavy server side "applications", even the C++ ones take a while to startup.

  93. Re:How much difference do these options really mak by medv4380 · · Score: 1

    Then learn to be a good Sysadmin and set the memory limits for processes using the OS. Using the Java Xmx setting will only screw with the Garbage Collection, and you'll still not have accounted for the GC and VM overhead. I can actually tell Java to use 128megs and it still take 200. If you're trying to optimize the performance of the Garbage Collector then go ahead start fiddling with them. Other systems have ether determined that it's not worth the hassle or have figured out a better way of managing heap size Garbage Collection Ratios.

  94. Re:How much difference do these options really mak by Bill,+Shooter+of+Bul · · Score: 1

    " And the application will run, unchanged, no matter what the users priorities are with regards to things like heap sizes, GC techniques, etc. That is pretty much the very essence of "write once, run anywhere"."

    No, the application's performance is very much affected by run time switches, obviously. I can cause it to completly not run at all, with a run time switch, by setting the heap to a ridicoulously small number.

    But the main point in our disagreement is you have an exceedingly small ability to understand abstract concepts. When people talk about the "spirit of open source" they are talking about more than strict license compliance. When I speak of "write once, run anwhere", I speak of more than just what the developer does ( the write part), but also what someone who uses the application does (the run part), and I assume the purpose of the heap size run time flag was part of that same line of thinking.

    --
    Well.. maybe. Or Maybe not. But Definitely not sort of.
  95. Re:Futile by LizardKing · · Score: 1

    All that shows is that it takes the resources of a Google and an app architecture that acknowledges any large program written in C/C++ will leak in order to create a "snappy" app that doesn't crash. (Although I've seen colleagues crash Chrome plebty of times). Bascially, I've worked for too many companies with labyrinthine, buggy C++ codebases to want to use that boondoggle of a language again. There's only so many times I could bear working on bugs related to thread issues caused by the myriad ways encapsulation can be broken in C++, or others where it was down to Stroustrup's knack of making the wrong decision whenever he was faced with a choice in how to implement a part of the C++ object model.

  96. Re:How much difference do these options really mak by SplashMyBandit · · Score: 1

    In production I have had to change the garbage collector limits to stop it thrashing when the total size of objects was near the default heap size.
    You do need to have this ability, and the O/S doesn't provide it (you can't control the garbage collector using O/S switches). Oh, and if the overhead of the VM is 72M you can easily do the math to determine what size to set for you memory limit - again, at least you have the ability to do this with Java. So, the memory limit switch can be used in two ways.

  97. Re:Futile by Daniel+Phillips · · Score: 1

    All that shows is that it takes the resources of a Google and an app architecture that acknowledges any large program written in C/C++ will leak in order to create a "snappy" app that doesn't crash.

    Wow, that's funny considering A) Google's apps are generally embarrassingly overweight and sloppily coded and B) most of the best C++ apps come from small teams or inviduals. Can you spell Carmack?

    --
    Have you got your LWN subscription yet?
  98. Re:How much difference do these options really mak by medv4380 · · Score: 1

    Thus we are back to my original point. The Java memory switches are for Garbage Collection Management. They are not as you put it so the "System administrators can also partition what any application can do, in case one is rogue". They are there so that you can adjust the GC, and your OS has its own controls to stop an application from going Rogue and taking down your system. Using them as memory limits to prevent an application from going rogue is counter productive to using them to optimize garbage collection.

  99. Re:How much difference do these options really mak by SplashMyBandit · · Score: 1

    The switches were designed for, and are used for, more than one purpose. It is that simple.