Instrumentation-based profiling has many advantages and one serious disadvantage: usually high performance overhead. This overhead could be substantially reduced if only a small portion of the target application (for example, one that has previously been identified as a bottleneck, or just one for which a developer is responsible) is instrumented, while the rest of the application code runs at full speed. The value of such a profiling technology would increase further if the code could be instrumented and de-instrumented as many times as needed at run time.
JFluid (http://research.sun.com/projects/jfluid) is an experimental profiling system, which includes a modified Java HotSpot VM and a GUI tool, and addresses both of the above issues. It allows a user to attach the tool to the VM started without any special preparation, dynamically instrument and de-instrument one or more application methods, and obtain profiling data on-line. Our tool supports instrumentation of a group of methods defined as an arbitrary "root" method plus all methods that it calls (a call subgraph) for CPU and object allocation profiling. It appears that static determination of all methods in a call subgraph is difficult in presence of virtual methods, bug fortunately, with dynamic code hotswapping available, two schemes of dynamic call subgraph revelation and instrumentation can be suggested. The technology for dynamic, selective code instrumentation appears to be very useful in practice for profiling large applications with many threads, for which conventional "total" instrumentation often does not scale.