Large overhead for simple example. How to reduce?

Questions about YourKit Java Profiler
Post Reply
randomtext
Posts: 4
Joined: Thu May 19, 2016 9:19 am

Large overhead for simple example. How to reduce?

Post by randomtext »

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
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

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

Post by Anton Katilin »

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
randomtext
Posts: 4
Joined: Thu May 19, 2016 9:19 am

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

Post by randomtext »

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

Thank you!
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

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

Post by Anton Katilin »

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

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

Post by Anton Katilin »

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.
randomtext
Posts: 4
Joined: Thu May 19, 2016 9:19 am

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

Post by randomtext »

What is the difference between _disable_exception_events and disablestacktelemetry (or exceptions=disable and exceptions=off)?
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

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

Post by Anton Katilin »

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: 6172
Joined: Wed Aug 11, 2004 8:37 am

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

Post by Anton Katilin »

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.
randomtext
Posts: 4
Joined: Thu May 19, 2016 9:19 am

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

Post by randomtext »

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.
Post Reply