Eye on Java performance Improvements
An anonymous reader writes "Performance. It's the one aspect of the Java platform that continually takes abuse. But the overwhelming success of the platform on other fronts makes performance issues worth serious investigation. In this article, Intrepid optimizers Jack Shirazi and Kirk Pepperdine, Director and CTO of JavaPerformanceTuning.com, look at compilation speed, exceptions, and heap size tuning."
Why?
Because if performance is an issue, you find your bottleneck and replace the
bottleneck Python code with a C module.
Suddenly your Python "Script" runs 99% as fast as if you'd written it in
C in the first place.
That's why nobody ever dogs on Python for being slow: Python makes it simple
to get the performance you'd expect from C while only requiring a minimal
amount of actual C code to be written.
*sigh* back to work...
Only throw Exceptions in "exceptional" cases, because they will slow things down? Again, advice I've been hearing since the early days.
One tip from Java Performance Tuning by Jack Shirazi is to create the Exception once, store it statically, and throw the object as many times as you need to.
Ugly? Sure. Hacky? Definitely.
But if you're after that extra bit of performance without leaving Java, need to use exceptions, and don't care about the stack trace, then it saves many cycles.
One thing that I've found with hig performance numerical routines is the cost of array lookup (with all of its runtime range checking) is something that can really slow a routine down. I've taken a routine that ran in 500ms and tuned it down to about 80ms (running under the Hotspot compiler). A comparable hand optimized assembler routine doing the same job took 20ms.
One example doesn't make a trend... but when you know what you're doing the performance is there for the taking.
Ian.
A physicist is an atom's way of thinking about atoms