@AuxCounters-like solution for events with stack traces?

Dmitry Chuyko dmitry.chuyko at bell-sw.com
Fri Sep 8 22:09:32 UTC 2017


Hi Chris,

What you describe sounds more like a custom JMH profiler, not a counter. You are able to create and use one looking to existing built-in profilers like StackProfiler. Or you can dump and study JFR recordings for your JMH runs if you use Oracle JDK.

Just curious, is AllocationRecorder you use an instrumenting Java agent or maybe exactly the one from google/allocation-instrumenter?

-Dmitry

> 8 сент. 2017 г., в 22:22, Chris <seahen123 at gmail.com> написал(а):
> 
> Hi all,
> 
> I have a benchmark where way too many objects are being created, but I have
> no idea where or what class. Would it be possible, using @AuxCounters or
> something similar, to emit something like a HashMultiset<StackTrace> or
> Map<StackTrace, Integer> for reporting? StackTrace is a simple wrapper I've
> built around StackTraceElement[] that does a truncation in the constructor
> and implements equals, hashCode and toString.
> 
> Failing that, is it possible that JMH is swallowing the output of these
> methods? Because either that, or
> com.google.monitoring.runtime.instrumentation.AllocationRecorder isn't
> working. If the output *is* being swallowed, how do I re-enable it?
> 
> // FIXME: Why isn't this outputting anything?
> @Setup(Level.Trial)
> public void setUp() {
>  AllocationRecorder.addSampler((arrayLength, desc, newObj, size) -> {
>    if (!desc.contains("StackTrace")) {
>      LOG.info("Created %s (a %s of %d bytes)\n", newObj, desc, size);
>      stackTraces.add(new
> StackTrace(Thread.currentThread().getStackTrace()));
>    }
>  });
> }
> 
> // FIXME: Why isn't this outputting anything either?
> @TearDown(Level.Trial)
> public void tearDown() {
>  System.gc();
>  for (StackTrace stackTrace : stackTraces) {
>    LOG.info("%d objects created from:\n%s\n",
> stackTraces.count(stackTrace), stackTrace);
>  }
>  stackTraces.clear();
> }



More information about the jmh-dev mailing list