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

谁说我不能喝 提交于 2019-12-12 18:12:15

问题


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:


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:



来源:https://stackoverflow.com/questions/7867611/how-to-use-jprofiler-custom-probe-telemetry-for-monitoring-guava-cache-statistic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!