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.

Large overhead for simple example. How to reduce?

Moderators: Vladimir Kondratyev, Anton Katilin

Large overhead for simple example. How to reduce?

Postby randomtext » Thu May 19, 2016 9:26 am

Hello,
im referring to following example:

Code: Select all
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class DateTimeFormatterBenchmark {
    public static void main(String[] args) {
        long startTime = System.nanoTime();
        LocalDate date = LocalDate.of(2000, 1, 1);
        for (int i = 0; i < 10000000; i++) DateTimeFormatter.BASIC_ISO_DATE.format(date);
        System.out.printf("%.3f s\n", (System.nanoTime() - startTime) / 1000000000.);
    }
}


Without yourkit agent: 11,595 s

With -agentpath:"C:\magicyourkitpath\bin\win64\yjpagent.dll"=disablestacktelemetry,disablealloc,probe_disable=*: 258,586 s

Why does the agent causing so much overhead? Are there any additional args to reduce it?

YourKit Version: 2016.02-b36
Java Version: 1.8.0_92 64-bit
randomtext
 
Posts: 4
Joined: Thu May 19, 2016 9:19 am

Re: Large overhead for simple example. How to reduce?

Postby Anton Katilin » Fri May 20, 2016 1:30 pm

Hi,

The problem is caused by a huge number of exception events being thrown. To work this around, please add the startup option _disable_exception_events
Anton Katilin
 
Posts: 5576
Joined: Wed Aug 11, 2004 8:37 am

Re: Large overhead for simple example. How to reduce?

Postby randomtext » Mon May 23, 2016 7:43 am

With -agentpath:"C:\magicyourkitpath\bin\win64\yjpagent.dll"=_disable_exception_events: 13,838 s

Thank you!
randomtext
 
Posts: 4
Joined: Thu May 19, 2016 9:19 am

Re: Large overhead for simple example. How to reduce?

Postby Anton Katilin » Mon May 23, 2016 8:10 am

Thank you for the confirmation.
Anton Katilin
 
Posts: 5576
Joined: Wed Aug 11, 2004 8:37 am

Re: Large overhead for simple example. How to reduce?

Postby Anton Katilin » Tue May 24, 2016 10:50 am

Update: the next major version will introduce a new set of startup options to control exception telemetry: exceptions=disable (the same as current _disable_exception_events), exceptions=on, exceptions=off.
Anton Katilin
 
Posts: 5576
Joined: Wed Aug 11, 2004 8:37 am

Re: Large overhead for simple example. How to reduce?

Postby randomtext » Tue May 24, 2016 1:14 pm

What is the difference between _disable_exception_events and disablestacktelemetry (or exceptions=disable and exceptions=off)?
randomtext
 
Posts: 4
Joined: Thu May 19, 2016 9:19 am

Re: Large overhead for simple example. How to reduce?

Postby Anton Katilin » Tue May 24, 2016 1:35 pm

In current version:

disablestacktelemetry: JVM exception events enabled, exception telemetry not started (can be started later)
disablestacktelemetry,_disable_exception_events: JVM exception events disabled, exception telemetry is not started and cannot be started later

In future version:

exceptions=disable: JVM exception events disabled, exception telemetry is not started and cannot be started later (the same as the current combination disablestacktelemetry,_disable_exception_events)

exceptions=off: JVM exception events enabled, exception telemetry is not started but can be started later (the same as current disablestacktelemetry)

exceptions=on: JVM exception events enabled, exception telemetry starts immediately, and of course can be turned off and on in runtime
Anton Katilin
 
Posts: 5576
Joined: Wed Aug 11, 2004 8:37 am

Re: Large overhead for simple example. How to reduce?

Postby Anton Katilin » Tue May 24, 2016 1:54 pm

Some explanation:

A profiling agent that uses the JVMTI API can ask the JVM to notify it about occurring exceptions by enabling the exception event. The event can only be enabled on the JVM start, as the existing JVMs do not allow to enable it at a later stage. In other words, you cannot ask the JVM to turn it on or off on demand.

When the event is enabled, there is no noticeable overhead in most cases.

The profiler's exception telemetry feature processes (records) the exception events. The event processing adds overhead, but it is also small in most cases. When the exception telemetry is not running, the event processing code is a no-op and the only overhead is the JVM's activity for issuing the event which, as said above, is usually negligible.

Your example is very special and unusual as it throws a huge number of exceptions in a loop. This is not a normal application's pattern, and in this particular case the usually small overhead becomes big. That's why your example benefited from disabling (i.e. not enabling) the event.
Anton Katilin
 
Posts: 5576
Joined: Wed Aug 11, 2004 8:37 am

Re: Large overhead for simple example. How to reduce?

Postby randomtext » Tue May 24, 2016 2:13 pm

Thanks for the explanation!

With -agentpath:"C:\magicyourkitpath\bin\win64\yjpagent.dll"=_disable_exception_events: 13,558 s

With -agentpath:"C:\magicyourkitpath\bin\win64\yjpagent.dll"=disablestacktelemetry: 273,176 s

Our software is convertering a large number of dates and it made a huge difference. It's too bad the converter is throwing so many exceptions. Some Scala functions are also problematic.
randomtext
 
Posts: 4
Joined: Thu May 19, 2016 9:19 am


Return to Java Profiler

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 5 guests