@AuxCounters-like solution for events with stack traces?

Nitsan Wakart nitsanw at yahoo.com
Sat Sep 9 15:28:31 UTC 2017


It would be good to integrate async-profiler as a JMH profiler. I might have a look at that next month. It support CPU and allocation profiling and should be reasonably straightforward to setup.

> On 9 Sep 2017, at 01:16, Chris <seahen123 at gmail.com> wrote:
> 
> More or less the latter, I think;
> it's com.google.monitoring.runtime.instrumentation.AllocationRecorder from
> the Maven artifact
> com.google.code.java-allocation-instrumenter:java-allocation-instrumenter:3.0.1.
> 
> On Fri, Sep 8, 2017 at 3:09 PM Dmitry Chuyko <dmitry.chuyko at bell-sw.com>
> wrote:
> 
>> 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