Sampling profiler can't measure walltime for remote calls

Questions about YourKit Java Profiler
Locked
Andrei.L
Posts: 35
Joined: Thu Mar 12, 2009 5:23 am

Sampling profiler can't measure walltime for remote calls

Post by Andrei.L »

We are using Yourkit for a decade (and have bought a license), and this is the first time I've stumbled over such crazy issue.

There must be either a huge bug in the profiler or a huge gap in the documentation, but we are unable to use sampling profiler to get meaningful results.

We have an application that communicates with other process via network, calls remote API synchronously.
Expectation is that if using sampling settings like below we would see also those calls in the method list.

Code: Select all

walltime=*
sampling_period_ms=1
Assuming the external process spent 3 seconds to complete the call, our expectation was the method that calls this external task would also be shown with 3 seconds at least in the method list. But surprisingly, the method that calls external process wasn't shown in the list or, if shown, only with 1-2 ms.

Note: exact same application instance profiled with JProfiler works out of the box and shows expected picture.
Yourkit also shows no errors and except the missing data everything else seem to work as expected.

We have enabled/disabled all filters, tried all possible sampling wildcards, but there seem to be no way to convince Yourkit to show walltime properly for all methods, except one uses wildcard for exact the method that we know spends time. But we don't know upfront, which method / class will be slow, it's the profiler job to find that out!

So with this settings it works for this concrete sleepSeconds2 method that mimics external process. However, this is not a solution for us: we have gazillions of classes and methods that call remote API, we need a wildcard that allows us to see walltime for all classes & methods.

Code: Select all

walltime=ProfilingExternalTime : sleepSeconds2(*)

sampling_period_ms=1
Example code:

Code: Select all

import java.util.concurrent.TimeUnit;

public class ProfilingExternalTime {

	public static void main(String[] args) {
        executeExternalTask();
        sleepSeconds(1);
    }

    static void executeExternalTask() {
        long start = System.nanoTime();
        sleepSeconds2(3);
        long stop = System.nanoTime();
        System.out.format("measurement took: %.2f sec%n", (float)(stop - start) / 1000_000_000);
    }

    static void sleepSeconds(int seconds) {
        try {
            TimeUnit.SECONDS.sleep(seconds);
            System.out.println("Done sleeping " + seconds + " seconds.");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    static void sleepSeconds2(int seconds) {
        try {
            ProcessBuilder pb = new ProcessBuilder("sleep", "" + seconds);
            Process process = pb.start();
            process.waitFor(seconds, TimeUnit.SECONDS);
            System.out.println("Done sleeping " + seconds + " seconds.");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
We have tried Yourkit 2021.3-b231 and 2021.3-b233 on OpenJDK Java 11.0.10 on RHEL 7.4.
Neither sampling settings like below show sleepSeconds2 :-(

walltime=*
walltime=*.*
walltime=*.*:*(*)

Code: Select all

uname -a
Linux socbm599 3.10.0-862.3.2.el7.x86_64 #1 SMP Tue May 15 18:22:15 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
It would be good to either get an example of the sampling settings that would allow us to see real time spent in such code like sleepSeconds2 using wildcards without using method or class names or to get a fixed Yourkit version.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Sampling profiler can't measure walltime for remote call

Post by Anton Katilin »

Please try adding the following line to the file <user home>/.yjp/ui.ini and restart the profiler UI:

-Dyjp.zero.time.methods=false
Andrei.L
Posts: 35
Joined: Thu Mar 12, 2009 5:23 am

Re: Sampling profiler can't measure walltime for remote call

Post by Andrei.L »

Thanks, that worked for the simple example, I'm going to verify with the original application (will take time).

Note 1: for Eclipse, the system property should be set in the appropriate launch configuration, because ~/.yjp/ui.ini seem to have no effect if starting profiler from Eclipse.
Note 2: the walltime=* option (still) must be used for sampling settings to be able to see all classes/methods.

Question: could you please add this information to the official documentation at https://www.yourkit.com/docs/java/help/ ... ttings.jsp?
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Sampling profiler can't measure walltime for remote call

Post by Anton Katilin »

Note 1: for Eclipse, the system property should be set in the appropriate launch configuration, because ~/.yjp/ui.ini seem to have no effect if starting profiler from Eclipse.
Do you mean that the profiler UI started standalone and started from within Eclipse as the result of "Profile" have different home directories?
Please ensure you edit ui.ini in appropriate user home directories.
Note 2: the walltime=* option (still) must be used for sampling settings to be able to see all classes/methods.
Yes.
Question: could you please add this information to the official documentation
We'll consider doing that. A better solution would be to get rid of that hidden option altogether or at least reconsider its default behavior.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Sampling profiler can't measure walltime for remote call

Post by Anton Katilin »

I'm going to verify with the original application (will take time).
Please note that since it's a UI option, you don't need to re-run the profiled application to apply it. If you have an existing snapshot just open it.
Andrei.L
Posts: 35
Joined: Thu Mar 12, 2009 5:23 am

Re: Sampling profiler can't measure walltime for remote call

Post by Andrei.L »

OK, all right, I was able to open old application snapshot and see the remote calls time properly added to the calling local method execution times.

So the remaining piece would be to get a profiler build that would do that "out of the box" 8) , or at least document this behavior in the manual.

Thanks for the fast help!
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Sampling profiler can't measure walltime for remote call

Post by Anton Katilin »

Thank you for the feedback. We have added a feature request to improve the out-of-the-box experience.
Andrei.L
Posts: 35
Joined: Thu Mar 12, 2009 5:23 am

Re: Sampling profiler can't measure walltime for remote call

Post by Andrei.L »

Thanks!
Locked