Optimization is one of the most interesting processes in software development. Every time your application needs performance improvement, you apply optimization.
What is optimization? Optimization is generally reducing resources usage. Which resources are applicable here?
When people talk about optimization, they most often mean CPU and memory usage. How can we achieve that? From the programming point of view, there are few well-known approaches:
However before you start your optimization process you should be aware that compiler and JVM perform most of the optimization routines implicitly. How can compiler affect optimization? It can throw away dead code, make constant folding and fixed expression evaluation.
However, the real genius of optimization is JVM. Hotspot JVM together with JIT compiler can reach similar functionality comparing to low-level languages (for example, C). The wide range of supported improvements includes:
I can summarize in conclusion that optimization is heuristic multi-step process that requires a lot of knowledge and experience from developer. You should have ultimate algorithmic skills in, know JVM and JDK internals and measure your performance changes.
Article written by:
Sergey Morenets – Java Evangelist