Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27088

Re: Question about Pattern.matcher performance differences between Java6 and Java7/8

From Arved Sandstrom <asandstrom2@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Question about Pattern.matcher performance differences between Java6 and Java7/8
References <fb06cd3d-4dd0-4a16-90ad-ad99d1a64a3e@googlegroups.com> <l9c5rb$1kt$1@dont-email.me> <mcmurtrie-B26298.11471925122013@c-61-68-245-199.per.connect.net.au>
Message-ID <2EZuu.83318$O25.50973@fx21.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2013-12-26 13:25 -0400

Show all headers | View raw


On 12/25/2013 03:47 PM, Kevin McMurtrie wrote:
> In article <l9c5rb$1kt$1@dont-email.me>,
>   Eric Sosman <esosman@comcast-dot-net.invalid> wrote:
>
>> On 12/24/2013 7:26 AM, zach.lists@gmail.com wrote:
>>> Hello,
>>>
>>> I've noticed a difference in performance between Java6 and Java7/8 (Oracle)
>>> on OS X with some toy code. Java6 runs much faster than the updated
>>> versions.
>>>
>>> VisualVM is pointing me to java.util.regex.Pattern.matcher being the
>>> hotspot where all the time is now spent.
>>>
>>> I'm still trying to slim down the offending code into a concise example.
>>> However I was wondering if anyone knew if there were any changes in
>>> java.util.regex.Pattern.matcher performance between Java6 and Java7?
>>>
>>> I've read that named groups were introduced in Java7, but I haven't found
>>> anything mentioning performance tanking dramatically.
>>>
>>> Thanks for any leads you folks may be able to point me to.
>>
>>       One suggestion: Don't fret about the performance of "toy code."
>>
>>       If the performance of "real code" suffers, that's another matter.
>> Note, though, that if Pattern.matcher() has suddenly become the hot
>> spot in real code it doesn't necessarily follow that Pattern.matcher()
>> has become slower.  It might instead mean that something else is now
>> matching a lot more regexes than it used to, or is using a more
>> complex regex than before.  If your car's fuel economy suddenly gets
>> worse it doesn't prove the engine's gone bad, it may instead have
>> something to do with the boat trailer you've hitched on ...
>
> Note that "real code" is difficult to accurately profile in Java.
> Instrumentation causes extremely intrusive de-optimization.  Sampling
> can only see safepoints, which can be sparse or in odd locations.
> Neither can determine real GC load.  What ends up happening is that you
> pull a chunk of suspect code out of your app and run it by itself in a
> controlled environment to benchmark it.  The alternative is using a
> native profiler and trying to manually correlate CPU instructions with
> Java source after HotSpot has moved everything around.
>
>
> When I benchmark one of my large apps using sampling, Integer.hashCode()
> sometimes makes the top ten CPU consumers.  The call count is normal and
> there's absolutely no code inside Integer.hashCode().  That's just where
> HotSpot likes dropping a safepoint in my app.
>
My first (and second and third) instinct has been for a long time to use 
profilers to get somewhat coarse timing information, and at the same 
time to get somewhat coarse function/method usage frequency information. 
And not really because of runtime optimizations either; much more 
because the last-mile analysis through human code review is most 
effective at analyzing performance issues if provided initial data.

AHS
-- 
When a true genius appears, you can know him by this sign:
that all the dunces are in a confederacy against him.
-- Jonathan Swift

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Question about Pattern.matcher performance differences between Java6 and Java7/8 zach.lists@gmail.com - 2013-12-24 04:26 -0800
  Re: Question about Pattern.matcher performance differences between Java6 and Java7/8 Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-12-24 09:31 -0500
    Re: Question about Pattern.matcher performance differences between Java6 and Java7/8 Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2013-12-25 11:47 -0800
      Re: Question about Pattern.matcher performance differences between Java6 and Java7/8 Robert Klemme <shortcutter@googlemail.com> - 2013-12-26 13:51 +0100
      Re: Question about Pattern.matcher performance differences between Java6 and Java7/8 Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-12-26 08:51 -0500
      Re: Question about Pattern.matcher performance differences between Java6 and Java7/8 Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-12-26 13:25 -0400

csiph-web