Fw: throwing static exceptions sometimes VERY slow! (original) (raw)

Wieland, Jacob Jacob.Wieland at spirent.com
Thu Mar 2 13:54:39 UTC 2017


0: loops: 1000000000 66 1 java.lang.Object:: (1 bytes) 68 2 java.lang.Number:: (5 bytes) 69 3 n java.lang.System::nanoTime (native) (static) 84 4 java.lang.String::indexOf (70 bytes) 86 5 java.lang.String::hashCode (55 bytes) 0: Thu Mar 02 14:50:41 CET 2017: 178532 88 6 java.util.concurrent.atomic.AtomicLong::get (5 bytes) 88 8 n sun.misc.Unsafe::compareAndSwapLong (native) 88 7 java.util.concurrent.atomic.AtomicLong::compareAndSet (13 bytes) 88 9 java.util.Random::next (47 bytes) 88 10 java.math.BigInteger::add (178 bytes) 97 11 java.math.BigInteger::valueOf (62 bytes) 97 12 java.math.BigInteger:: (77 bytes) 98 13 java.math.BigInteger:: (24 bytes) 98 14 java.math.BigInteger::add (123 bytes) 98 15 java.lang.Math::random (17 bytes) 99 16 java.util.Random::nextDouble (24 bytes) 101 17 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ 70 (549 bytes) 123 17 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ -2 (549 bytes) made not entrant 124 18 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ 70 (549 bytes) 8802 18 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ -2 (549 bytes) made not entrant 0: Thu Mar 02 14:50:50 CET 2017: 620776 8803 19 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ 70 (549 bytes) 0: Thu Mar 02 14:50:56 CET 2017: 128566 21909 19 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ -2 (549 bytes) made not entrant 21909 14 java.math.BigInteger::add (123 bytes) made not entrant 21909 10 java.math.BigInteger::add (178 bytes) made not entrant 21911 20 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ 70 (549 bytes) 21914 21 java.math.BigInteger::add (178 bytes) 21921 22 java.math.BigInteger::add (123 bytes) 0: Thu Mar 02 14:51:04 CET 2017: 2974443 0: Thu Mar 02 14:51:05 CET 2017: 103290 44839 20 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ -2 (549 bytes) made not entrant 44840 23 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ 70 (549 bytes) 0: Thu Mar 02 14:51:35 CET 2017: 2076623 0: Thu Mar 02 14:51:36 CET 2017: 333400 0: Thu Mar 02 14:51:37 CET 2017: 240985 0: Thu Mar 02 14:51:39 CET 2017: 1360262 0: Thu Mar 02 14:51:40 CET 2017: 2993867 0: Thu Mar 02 14:51:48 CET 2017: 794752 67360 22 java.math.BigInteger::add (123 bytes) made not entrant 67362 24 java.math.BigInteger::add (123 bytes) 0: Thu Mar 02 14:52:03 CET 2017: 146861 0: Thu Mar 02 14:52:14 CET 2017: 312026 0: Thu Mar 02 14:52:23 CET 2017: 353730 104327 23 % ! de.tu_berlin.cs.uebb.muttcn.runtime.Test::measure @ -2 (549 bytes) made not entrant 104327 11 java.math.BigInteger::valueOf (62 bytes) made not entrant 0: longThrows: 14 average time: 901293 0: shortThrows: 999999986 average time: 19 0: sum: 19999665505 0: average throw time: 19

That was run using nice -19 to minimize interaction with other processes.

BR

[X]

Dr. Jacob Wieland

Senior Software Engineer

main +49.30.7261919.34

mobile +49.173.6446443

jacob.wieland at spirent.com<mailto:jacob.wieland at spirent.com>

www.spirent.com

Follow us on:

Spirent Communications

<https://www.linkedin.com/company/spirent-communications>[X]<https://www.linkedin.com/company/spirent-communications>|<https://twitter.com/Spirent>[X]<https://twitter.com/Spirent>|<https://www.facebook.com/spirent>[X]<https://www.facebook.com/spirent>

Michaelkirchstraße 17/18

10179 Berlin, Germany

+++++ N E W S F L A S H +++++

Spirent Communications and Testing Technologies join forces to become your test automation power-house. Read more at http://conta.cc/1S62BEY.


From: Vitaly Davidovich <vitalyd at gmail.com> Sent: Thursday, March 2, 2017 2:45:15 PM To: Wieland, Jacob Cc: Ioi Lam; hotspot-dev at openjdk.java.net Subject: Re: Fw: throwing static exceptions sometimes VERY slow!

That's the safepoint stats, which is good to see - looks like a lot of GC activity. Is that also the case for your real application? GC activity like that could cause jitter but you mentioned in your original email that you ruled it out somehow?

But, I was asking to see the PrintCompilation output in my last email :). There's no Deoptimize safepoint entry in the safepoint log here, but would still be interesting to see JITs compilation log.

On Thu, Mar 2, 2017 at 8:36 AM Wieland, Jacob <Jacob.Wieland at spirent.com<mailto:Jacob.Wieland at spirent.com>> wrote:

here you are

BR

[X]

Dr. Jacob Wieland

Senior Software Engineer

main +49.30.7261919.34

mobile +49.173.6446443

jacob.wieland at spirent.com<mailto:jacob.wieland at spirent.com>

www.spirent.com<http://ww.spirent.com>

Follow us on:

Spirent Communications

<https://www.linkedin.com/company/spirent-communications>[X]<https://www.linkedin.com/company/spirent-communications>| <https://twitter.com/Spirent> [X] <https://twitter.com/Spirent> | <https://www.facebook.com/spirent> [X] <https://www.facebook.com/spirent>

Michaelkirchstraße 17/18

10179 Berlin, Germany

+++++ N E W S F L A S H +++++

Spirent Communications and Testing Technologies join forces to become your test automation power-house. Read more at http://conta.cc/1S62BEY.


From: Vitaly Davidovich <vitalyd at gmail.com<mailto:vitalyd at gmail.com>> Sent: Thursday, March 2, 2017 1:45:43 PM To: Wieland, Jacob Cc: Ioi Lam; hotspot-dev at openjdk.java.net<mailto:hotspot-dev at openjdk.java.net>

Subject: Re: Fw: throwing static exceptions sometimes VERY slow! So how about PrintCompilation output?

On Thu, Mar 2, 2017 at 7:31 AM, Wieland, Jacob <Jacob.Wieland at spirent.com<mailto:Jacob.Wieland at spirent.com>> wrote:

I have modified the exception to not writable and disallow supression, but as I would have expected, no change in behavior was observed. Also, if only one thread is running and lock contention was an issue, should that not go away in that case (it doesn't). The other question if have regarding this is: if the exception is static, should fillInStackTrace() not be called only when creating that way before it is actually thrown? Why would that have any influence on the later throw?

If it was just garbage collection, I would assume the GC output (if turned on) happening close to the long-throw output (it doesn't, as far as I can see).

The most interesting observation about this (imho) is that the number of cases seems to be very reproducible, even over different threads, so there seems to be some non-random relationship (which of course could still be related to the underlying platform doing stuff at regular intervals or sth). Maybe I should measure also the distance between the long throws and see whether they are happening regularly or in clumps.

My next experiment will be if the same behavior can be observed with a normal fast operation, but I doubt that as well, because then eliminating the throws from the original example where I observed this first should not have had any positive effect.

Of course, another candidate could also be the System.nanoTime() itself which for some reason might contend on the system level for resources sometimes, but I have no idea how to measure that! [??]

BR

[X]

Dr. Jacob Wieland

Senior Software Engineer

main +49.30.7261919.34

mobile +49.173.6446443

jacob.wieland at spirent.com<mailto:jacob.wieland at spirent.com>

www.spirent.com<http://ww.spirent.com>

Follow us on:

Spirent Communications

<https://www.linkedin.com/company/spirent-communications>[X]<https://www.linkedin.com/company/spirent-communications>| <https://twitter.com/Spirent> [X] <https://twitter.com/Spirent> | <https://www.facebook.com/spirent> [X] <https://www.facebook.com/spirent>

Michaelkirchstraße 17/18

10179 Berlin, Germany

+++++ N E W S F L A S H +++++

Spirent Communications and Testing Technologies join forces to become your test automation power-house. Read more at http://conta.cc/1S62BEY.


From: Vitaly Davidovich <vitalyd at gmail.com<mailto:vitalyd at gmail.com>> Sent: Thursday, March 2, 2017 12:35:20 PM To: Ioi Lam; Wieland, Jacob; hotspot-dev at openjdk.java.net<mailto:hotspot-dev at openjdk.java.net> Subject: Re: Fw: throwing static exceptions sometimes VERY slow!

Ioi,

Argh, you're right about the formatting. I'll paste below my last reply to Jacob.

Instead of overriding fillInStacktrace, which is a synchronized method and you're sharing those instances between threads, can you construct the Continue and Break exceptions telling base class that you don't want writable stacktrace?

The jitter you're seeing could be lock contention due to above, biased lock revocation, JIT deoptimizations (although in your Test I'm not sure if it'll deoptimize since the throws are not uncommon).

You can add -XX:+PrintSafepointStatistics -XX:PrintSafepointStatisticsCount=1 to get reasons for safepoints printed to stdout.

As mentioned, run your test with -XX:+PrintCompilation to see if JIT is doing something.

On Thu, Mar 2, 2017 at 1:12 AM Ioi Lam <ioi.lam at oracle.com<mailto:ioi.lam at oracle.com>> wrote: Vitaly,

Thanks for forwarding the email. Unfortunately, the HTML formatting has been stripped by the mailing list so it's hard to see who said what :-(

I made a mockup-test (see attachment) that mimicks kind of what my generated code does and adds measurements before throw and after catch. Mostly, in my experiments with this, the throw takes on average 20 ns, but between a 1 and 3 per million iterations take longer than 1 ms, on average around 7 ms. It can be observed that doing a garbage collection in a different java process (namely my eclipse that started the test) greatly influences the frequency of the > 1 ms throws, so maybe it is simply a load issue. Using multiple threads in parallel also seems to heighten the

Perhaps the slow down is caused by GC?

One simple way to try is to run with different heap sizes, and use different type of collectors. If you observe different frequency of the outlier cases, then it's probably caused by GC pauses.

Jacob, could you post the mockup test again?

Thanks

Sent from my phone

-- Sent from my phone



More information about the hotspot-dev mailing list