Fully featured low overhead profiler for Java EE and Java SE platforms.
Ultimate profiling and monitoring solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

ReentrantLock not measured in sampling?

Moderators: Vladimir Kondratyev, Anton Katilin

ReentrantLock not measured in sampling?

Postby sanderbos » Thu May 18, 2017 7:58 am

Hello,

if I run a take a sample using YourKit of the following sample code:
Code: Select all
  private void run() throws Exception {
    for (int index = 0; index < 1000; index++) {
      justSleep();
      waitForReentrantLock();
    }
  }

  private void justSleep() throws InterruptedException {
    System.out.println("Sleeping");
    Thread.sleep(1000);
  }

  private void waitForReentrantLock() throws InterruptedException {
    System.out.println("Waiting");
    long endTime = System.currentTimeMillis() + 1000;
    ReentrantLock lock = new ReentrantLock();
    lock.lock();
    synchronized (lock) {
      lock.newCondition().awaitUntil(new Date(endTime));
    }
    lock.unlock();
  }


with
Code: Select all
walltime=*
so that everything is measured as real time, then the time spent in awaitUntil, which should be half of the time (and I sampled this sample for about one minute), is not measured:
Image
I tried it in regular attach mode, and with the yourkit agent loaded, on both Linux and Windows.

I this a known issue? Is there a way in which I can sample this time? If I cannot, are there other calls like this that cannot be monitored?

I found another post about this here: https://www.yourkit.com/forum/viewtopic.php?f=2&t=3362
But that post is quite old. It also says it is a generic JVM issue, but that is not true, because when sampling from jvisualvm this the waitForReentrantLock is measured just fine.
sanderbos
 
Posts: 8
Joined: Tue Mar 01, 2016 4:14 pm

Re: ReentrantLock not measured in sampling?

Postby sanderbos » Thu May 18, 2017 10:31 am

A collegue of mine has now pointed out that to see this information, you actually have to add

-Dyjp.zero.time.methods=false
to
~/.yjp/ui.ini

to see it.
Which I think is quite a remarkable thing to have enable explicitly (because since my previous post I also found that the same thing also happens for regular Object::wait calls).
sanderbos
 
Posts: 8
Joined: Tue Mar 01, 2016 4:14 pm

Re: ReentrantLock not measured in sampling?

Postby Anton Katilin » Sun May 21, 2017 1:50 pm

Yes, this option is intended to make such methods visible, which are invisible by default because a lot of users reported they wanted not to skip them instead. We have a feature request to make the switch more explicit.
Anton Katilin
 
Posts: 5575
Joined: Wed Aug 11, 2004 8:37 am


Return to Java Profiler

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron