How to use JProfiler custom probe telemetry for monitoring Guava cache statistics

1.3k views Asked by At

At JPL, we use model transformation techniques for our systems engineering work. We use the Eclipse QVTO implementation of OMG's QVT specification.

http://www.eclipse.org/modeling/m2m/downloads/index.php?project=qvtoml

However, the Eclipse QVTO compiler is frustratingly slow. With judicious application of Guava's cache, I've managed to make significant performance improvements to the Eclispe QVTO compiler. More could be done but with what I have, I would like to get a view of the effectiveness of the caching optimizations in place by monitoring the cache statistics at runtime; i.e, com.google.common.cache.CacheStats

Has anyone suggestions w.r.t. how to define a JProfiler custom telemetry probe to do this?

http://resources.ej-technologies.com/jprofiler/help/doc/indexRedirect.html?http&&&resources.ej-technologies.com/jprofiler/help/doc/helptopics/probes/custom.html

  • Nicolas.
1

There are 1 answers

3
Ingo Kegel On

For a single cache that you can access with a static method, it's fairly easy. In the custom probe wizard, set the meta-data script to

metaData.recordOnStartup(true);

metaData.telemetry(true);
metaData.addCustomTelemetry("Request count", Unit.PLAIN, 1f);
metaData.addCustomTelemetry("Hit count", Unit.PLAIN, 1f);
metaData.addCustomTelemetry("Hit rate", Unit.PERCENT, 1f);
metaData.addCustomTelemetry("Miss count", Unit.PLAIN, 1f);
metaData.addCustomTelemetry("Miss rate", Unit.PERCENT, 1f);
metaData.addCustomTelemetry("Load success count", Unit.PLAIN, 1f);
metaData.addCustomTelemetry("Load exception count", Unit.PLAIN, 1f);
metaData.addCustomTelemetry("Load exception rate", Unit.PERCENT, 1f);
metaData.addCustomTelemetry("Eviction count", Unit.PLAIN, 1f);
metaData.addCustomTelemetry("Total load time", Unit.MICROSECONDS, 1f);
metaData.addCustomTelemetry("Average load penalty", Unit.MICROSECONDS, 1f);

and the telemetry script to

import test.CacheTest;
import com.google.common.cache.*;

Cache cache = CacheTest.getSingleCache();
if (cache == null) {
    return;
}
CacheStats stats = cache.stats();
data[0] = (int)stats.requestCount();
data[1] = (int)stats.hitCount();
data[2] = (int)(stats.hitRate() * 100);
data[3] = (int)stats.missCount();
data[4] = (int)(stats.missRate() * 100);
data[5] = (int)stats.loadSuccessCount();
data[6] = (int)stats.loadExceptionCount();
data[7] = (int)(stats.loadExceptionRate() * 100);
data[8] = (int)stats.evictionCount();
data[9] = (int)stats.totalLoadTime() / 1000;
data[10] = (int)stats.averageLoadPenalty() / 1000;

where CacheTest.getSingleCache() is the hook to get at your cache.

This will get you telemetry for all cache statistics measurements, like shown in the screen shot below:

enter image description here