Old Generation GC and cache performance?
This is a question as much as a discussion, I can’t find a lot of detail on the state of play in this area and would really welcome any feedback or corrections. Please don’t read this as a negative article as that is not how it is intended; it’s in the optimisation section but I’m not sure what impact it really has. One thing for sure, for 99% of systems you probably don’t have to worry about what’s going on here at all.
Are we prone to over optimising code?
As a developer I often feel the need to performance tune code, or write “the best piece of code ever”. Sometimes this happens even before I know which sections of the code will be executed frequently? These days I make every attempt to hold back from this approach.
In applications where performance is critical I usually write it the most natural way and apply any optimisations required later. Usually in such systems I am more worried about garbage collection / not getting a cache hit for memory, than outright CPU performance. Generally speaking these days CPU time is cheap - not that I am condoning lax programming techniques.
GC monitoring in Java with Jstat
Recently I had a few performance problems with an application that required JVM GC monitoring. It had been so long since the last time I’d had to perform any CG analysis that I had to remind myself of what to do!
Using jps and jstat to get JVM GC statistics
First, ensure that an appropriate JDK is on your path
[dave@titan ~]$ java -version
java version "1.7.0_45"
OpenJDK Runtime Environment (fedora-2.4.3.0.fc19-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
Next, issue the command jps
which shows a list of all running Java processes that can be
interrogated.