-
Notifications
You must be signed in to change notification settings - Fork 64
Profiling
Precog (through BlueEyes) has a free license to use JProfiler an "award-winning all-in-one Java profiler". This page will describe how you can use JProfiler to help understand how your Scala code is executing, and using this information to reduce memory use, speed up slow regions, and generally write better code.
First you'll want to download a copy of JProfiler. When you open it for the first time you'll need to enter the following license key:
S-J7-BLUEEYES_OSS_PROJECT#50022085010001-yabh29pyvwb87t#222
JProfiler has the ability to attach to already-running JVM instances. So, if you have code (or tests) that you want to profile, a quick-and-dirty way to do this just to launch SBT, attach JProfiler, and then start running your actual code or test.
The big downside to this approach is it requires some manual intervention to get right, and the results will be interleaved with information about SBT's own performance. This means that certain tools like the CPU or allocation hotspot trackers might be giving the wrong information.
The other way to go is to generate a JProfiler snapshot directly from SBT. To do this you can use the existing jprofiler
subproject or create your own. With this option, SBT will fork a new Java process, load the profiling library, and then run your code. This option can require a bit more setup ahead of time but has some nice benefits:
- Avoid seeing allocations, memory, CPU for SBT
- Can be used remotely, on devci01, etc.
- Easier to reproduce later
The jprofiler
project is currently set up to profile queries. Edit jprofiler/src/main/scala/com/precog/jprofiler/Run.scala
to decide what query should be run (future work should make it easier to supply a new query on the command-line). Once you've done that, you can profile the query via:
$ sbt
> project jprofiler
> profile --runs 0 --dry-runs 1
(Profiling slows execution time down, so it's often smart to specify a small number of runs.)