Question

I'm puzzled by some performance of Clojure and Scala on the JVM, and I'm wondering what the best way to understand the cryptic functional code. Should I learn to grok the bytecode, or use a profiler to guess at performance? Would someone with experience recommend tools for this please? I understand that JD (http://java.decompiler.free.fr) is the best decompiler. Is this the route I should go down?

Was it helpful?

Solution

A decompiler will tell you very little about the performance of the code in flight. Reading the bytecode is only occasionally useful for understanding behaviour, and for more dynamic characteristics it will be even less useful. There are a few reasons for this. The first is that doing performance tuning based on static analysis isn't wise, will usually catch only blatant howlers, and may lead you to premature optimisations. The second is that what runs in the VM is not identical to the bytecode. The Just In Time compiler will make a number of optimisations, such as inclining short methods.

To see what the app is doing, performance wise, you really need a profiler. Figure out your heap usage and how much time is going to garbage collection, then use a sampling profiler to see which bits of code are taking the time. IBM's Health Center is a good one, or you could try Visual VM, or any number of others.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top