@AuxCounters-like solution for events with stack traces?

Chris seahen123 at gmail.com
Fri Sep 8 22:20:48 UTC 2017


UPDATE: Just so everyone knows, this question may now be moot in this
specific case, since
https://github.com/Pr0methean/BetterRandom/commit/c00f4e04104140129fcb76f8faadc1c0fa03a81c
seems
to have fixed the performance problem I was investigating.

On Fri, Sep 8, 2017 at 3:16 PM 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