The T-Files


Fri, 08 Feb 2008

Johnny can't add, part 8

External USB hard drives were on sale, so I picked up 500 GB from I-O Data and thanks to Time Machine now have a decent backup system in place. An interesting fact about hard disks is that there are two ways to count data volumes. Usually a kilobyte has 1024 bytes, with admittedly is somewhat at odds with the metric system. Hard disk makers call 1000 bytes a kilobyte. That is not much of a difference (2.35%), so you can ignore that as a marketing oddity, but the discrepancy grows dramatically as we get towards terabyte disks. A 1 MB hard disk really only holds 95.3% of a megabyte, a 1 GB disk only 93.1% of a GB, and my new 500 GB disk has only 465 GB.

PS:Caption inspired by Mike Camino Pinkerton's remarks on mathematics, marketing and McDonalds.

DTrace Envy

Probably the most acclaimed technology to come out of Sun Microsystems recently is DTrace, the dynamic tracing framework for Solaris (which Apple also ported for and included in Leopard). DTrace allows to inject so-called probes into the running operating system and applications in order to gather data to tune or troubleshoot them. Probes are written in a simple programming language called D, creating probes requires no changes to the code being probed, and DTrace support has no performance impact unless the probes are actually enabled.

I really want to have something similar for Java, in order to troubleshoot tricky support issues at customer sites. At least a simple version (with only JVM-level and no application-specific instrumentation points) should be possible using the existing JVM tracing and debugging interfaces. I picture something like inserting a little script that fires when a specific method is called with a specific set of arguments and then logs a message or starts a timer or increases a counter. Half a day of searching did unfortunately not turn up an easy-to-use and painless-to-deploy tool, although I am sure there must be something.

As it is, we have to rely on logging, the catch being, of course, that appropriate trace messages need to be in the code in the first place, which more often than not they are not, requiring a patch release with all the costs and delays associated to it. And even if the messages are there, they of course only appear when trace logging is enabled, and even when only enabling tracing for the bare minimum of log categories required, there will usually be a lot of output unrelated to the problem at hand that need to be manually filtered.

Update: I am aware that DTrace is available on the latest JVM for Solaris and Mac OS X, but that will not help me with Java5 on RedHat, which is what we deploy on. I was looking for a Javaland solution that works with older/other JVM/OS.