You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Vance Zhao <va...@gmail.com> on 2013/06/27 10:52:49 UTC
Perl5Matcher cause CPU spike
Hi,
Don't know if we have discussed this before but I found the regex lib we
used --"org.apache.oro.text.regex.Perl5Matcher"
<http://jakarta.apache.org/oro/>which will consume CPU spike time during
the load testing.
The response return in my case is soap which format as:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance">
<soap:Body xmlns:ns1="http://rfp.testdomain.testdomain.com/api/v4_0">
<ns4:getRfpResponse xmlns="
http://common.testdomain.testdomain.com/api/v1_0" xmlns:ns2="
http://rfp.testdomain.testdomain.com/v4_0" xmlns:ns3="
http://contact.testdomain.testdomain.com/v1_0" xmlns:ns4="
http://rfp.testdomain.testdomain.com/api/v4_0" xmlns:ns5="
http://common.testdomain.testdomain.com/v1_0">
<ns4:rfp>
<ns2:RfpOID>4DBC8638-BBE0-4626-97D6-004F111F0C2B</ns2:RfpOID>
<ns2:RfpName>Test</ns2:RfpName>
<ns2:RfpTitle>Test</ns2:RfpTitle>
<ns2:RfpLabel>12110</ns2:RfpLabel>
<ns2:Source>Test</ns2:Source>
<ns2:AttendeeQuantity>37</ns2:AttendeeQuantity>
<ns2:PlannerPreferredMeetingDate>
<ns2:ShoulderStartDate>2010-01-11</ns2:ShoulderStartDate>
<ns2:MeetingStartDate>2010-01-12</ns2:MeetingStartDate>
<ns2:MeetingEndDate>2010-01-15</ns2:MeetingEndDate>
</ns2:PlannerPreferredMeetingDate>
.................................................................................
The regex pattern I use is: <(.*)RfpOID>(.*)</(.*)RfpOID> to grape the
rfpOID for this response due to the namesapce prex "ns2" changes sometime
and the response of this api around big to 65k.
The CPU will be eat quickly when I use 20 threads user load
- *20 Threads* ( Jmeter thread eat 97% CPU)
And the thread dump from Jmeter is saying mosto the Jmeter Thread is
running for *Perl5Matcher*
*
"Before_getRfp 1-10" prio=6 tid=0x03067c00 nid=0x4874 runnable [0x04d8f000]
java.lang.Thread.State: RUNNABLE
at org.apache.oro.text.regex.Perl5Matcher.__match(Unknown Source)
at org.apache.oro.text.regex.Perl5Matcher.__match(Unknown Source)
at org.apache.oro.text.regex.Perl5Matcher.__tryExpression(Unknown
Source)
at org.apache.oro.text.regex.Perl5Matcher.__interpret(Unknown Source)
at org.apache.oro.text.regex.Perl5Matcher.contains(Unknown Source)
at
org.apache.jmeter.extractor.RegexExtractor.matchStrings(RegexExtractor.java:234)
at
org.apache.jmeter.extractor.RegexExtractor.processMatches(RegexExtractor.java:219)
at
org.apache.jmeter.extractor.RegexExtractor.process(RegexExtractor.java:118)
at
org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:737)
at
org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:438)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.lang.Thread.run(Unknown Source)*
Also, the single thread load also will jump to 25% CPU utilization
- *Single Thread* (Jmeter thread eat 25% CPU)
After that, I did some tests to compare Perl5Matcher with other Java perl5
regex lib ( I use jregex). Please check my code attached.
Time for using org.apache.oro.text.regex.Perl5Matcher 3801(ms)
Time for using jregex 13(ms)
*
*
Thanks for reading so long but I'd like to know if we can user other regex
lib for Jmeter.
Vance*
*
Re: Perl5Matcher cause CPU spike
Posted by Vance Zhao <va...@gmail.com>.
Thanks for response so fast :-)
After looking back to my Jmeter script code, I really agree with my regular
express is not efficient enough.
This is actually a good example for tuning the "Jmeter scripts".
Thank you
Vance
On Thu, Jun 27, 2013 at 5:30 PM, Thomas Johnson <nt...@gmail.com> wrote:
> As a quick question, is there any reason that you're not using the XPath
> extractor<
> http://jmeter.apache.org/usermanual/component_reference.html#XPath_Extractor
> >?
> It might be a bit easier to get the desired data that way if you have
> namespace support enabled. You could search for //*[local-name()='RfpOID'
> and namespace-uri()='http://rfp.testdomain.testdomain.com/v4_0']
>
> As for the regular expression, it looks like you're using a lot of greedy
> wildcards (.*) in there. This is forcing the regex engine to do loads of
> backtracking as it tries every possible permutation to find a match. You
> could probably clean this up by using non-greedy wildcards and more
> restrictive sets instead.
>
> I have nothing to test with right now, so my syntax could be a bit off, but
> something like <ns[0-9]+:RfpOID>(.*?)</ns[0-9]+:RfpOID> should work a
> little better. It'll match any RfpOID tag belonging to a numbered
> namespace.
>
>
> On Thu, Jun 27, 2013 at 10:52 AM, Vance Zhao <va...@gmail.com> wrote:
>
> > Hi,
> >
> > Don't know if we have discussed this before but I found the regex lib we
> > used --"org.apache.oro.text.regex.Perl5Matcher"
> > <http://jakarta.apache.org/oro/>which will consume CPU spike time during
> > the load testing.
> >
> >
> >
> > The response return in my case is soap which format as:
> >
> > <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> > xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance">
> > <soap:Body xmlns:ns1="http://rfp.testdomain.testdomain.com/api/v4_0">
> > <ns4:getRfpResponse xmlns="
> > http://common.testdomain.testdomain.com/api/v1_0" xmlns:ns2="
> > http://rfp.testdomain.testdomain.com/v4_0" xmlns:ns3="
> > http://contact.testdomain.testdomain.com/v1_0" xmlns:ns4="
> > http://rfp.testdomain.testdomain.com/api/v4_0" xmlns:ns5="
> > http://common.testdomain.testdomain.com/v1_0">
> > <ns4:rfp>
> > <ns2:RfpOID>4DBC8638-BBE0-4626-97D6-004F111F0C2B</ns2:RfpOID>
> > <ns2:RfpName>Test</ns2:RfpName>
> > <ns2:RfpTitle>Test</ns2:RfpTitle>
> > <ns2:RfpLabel>12110</ns2:RfpLabel>
> > <ns2:Source>Test</ns2:Source>
> > <ns2:AttendeeQuantity>37</ns2:AttendeeQuantity>
> > <ns2:PlannerPreferredMeetingDate>
> > <ns2:ShoulderStartDate>2010-01-11</ns2:ShoulderStartDate>
> > <ns2:MeetingStartDate>2010-01-12</ns2:MeetingStartDate>
> > <ns2:MeetingEndDate>2010-01-15</ns2:MeetingEndDate>
> > </ns2:PlannerPreferredMeetingDate>
> >
> >
> .................................................................................
> >
> > The regex pattern I use is: <(.*)RfpOID>(.*)</(.*)RfpOID> to grape the
> > rfpOID for this response due to the namesapce prex "ns2" changes sometime
> > and the response of this api around big to 65k.
> >
> > The CPU will be eat quickly when I use 20 threads user load
> >
> >
> > - *20 Threads* ( Jmeter thread eat 97% CPU)
> >
> >
> >
> > And the thread dump from Jmeter is saying mosto the Jmeter Thread is
> > running for *Perl5Matcher*
> > *
> > "Before_getRfp 1-10" prio=6 tid=0x03067c00 nid=0x4874 runnable
> [0x04d8f000]
> > java.lang.Thread.State: RUNNABLE
> > at org.apache.oro.text.regex.Perl5Matcher.__match(Unknown Source)
> > at org.apache.oro.text.regex.Perl5Matcher.__match(Unknown Source)
> > at org.apache.oro.text.regex.Perl5Matcher.__tryExpression(Unknown
> > Source)
> > at org.apache.oro.text.regex.Perl5Matcher.__interpret(Unknown Source)
> > at org.apache.oro.text.regex.Perl5Matcher.contains(Unknown Source)
> > at
> >
> >
> org.apache.jmeter.extractor.RegexExtractor.matchStrings(RegexExtractor.java:234)
> > at
> >
> >
> org.apache.jmeter.extractor.RegexExtractor.processMatches(RegexExtractor.java:219)
> > at
> >
> org.apache.jmeter.extractor.RegexExtractor.process(RegexExtractor.java:118)
> > at
> >
> >
> org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:737)
> > at
> >
> >
> org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:438)
> > at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
> > at java.lang.Thread.run(Unknown Source)*
> >
> > Also, the single thread load also will jump to 25% CPU utilization
> >
> >
> > - *Single Thread* (Jmeter thread eat 25% CPU)
> >
> > After that, I did some tests to compare Perl5Matcher with other Java
> perl5
> > regex lib ( I use jregex). Please check my code attached.
> >
> > Time for using org.apache.oro.text.regex.Perl5Matcher 3801(ms)
> >
> > Time for using jregex 13(ms)
> > *
> > *
> > Thanks for reading so long but I'd like to know if we can user other
> regex
> > lib for Jmeter.
> >
> > Vance*
> > *
> >
>
Re: Perl5Matcher cause CPU spike
Posted by Thomas Johnson <nt...@gmail.com>.
As a quick question, is there any reason that you're not using the XPath
extractor<http://jmeter.apache.org/usermanual/component_reference.html#XPath_Extractor>?
It might be a bit easier to get the desired data that way if you have
namespace support enabled. You could search for //*[local-name()='RfpOID'
and namespace-uri()='http://rfp.testdomain.testdomain.com/v4_0']
As for the regular expression, it looks like you're using a lot of greedy
wildcards (.*) in there. This is forcing the regex engine to do loads of
backtracking as it tries every possible permutation to find a match. You
could probably clean this up by using non-greedy wildcards and more
restrictive sets instead.
I have nothing to test with right now, so my syntax could be a bit off, but
something like <ns[0-9]+:RfpOID>(.*?)</ns[0-9]+:RfpOID> should work a
little better. It'll match any RfpOID tag belonging to a numbered namespace.
On Thu, Jun 27, 2013 at 10:52 AM, Vance Zhao <va...@gmail.com> wrote:
> Hi,
>
> Don't know if we have discussed this before but I found the regex lib we
> used --"org.apache.oro.text.regex.Perl5Matcher"
> <http://jakarta.apache.org/oro/>which will consume CPU spike time during
> the load testing.
>
>
>
> The response return in my case is soap which format as:
>
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance">
> <soap:Body xmlns:ns1="http://rfp.testdomain.testdomain.com/api/v4_0">
> <ns4:getRfpResponse xmlns="
> http://common.testdomain.testdomain.com/api/v1_0" xmlns:ns2="
> http://rfp.testdomain.testdomain.com/v4_0" xmlns:ns3="
> http://contact.testdomain.testdomain.com/v1_0" xmlns:ns4="
> http://rfp.testdomain.testdomain.com/api/v4_0" xmlns:ns5="
> http://common.testdomain.testdomain.com/v1_0">
> <ns4:rfp>
> <ns2:RfpOID>4DBC8638-BBE0-4626-97D6-004F111F0C2B</ns2:RfpOID>
> <ns2:RfpName>Test</ns2:RfpName>
> <ns2:RfpTitle>Test</ns2:RfpTitle>
> <ns2:RfpLabel>12110</ns2:RfpLabel>
> <ns2:Source>Test</ns2:Source>
> <ns2:AttendeeQuantity>37</ns2:AttendeeQuantity>
> <ns2:PlannerPreferredMeetingDate>
> <ns2:ShoulderStartDate>2010-01-11</ns2:ShoulderStartDate>
> <ns2:MeetingStartDate>2010-01-12</ns2:MeetingStartDate>
> <ns2:MeetingEndDate>2010-01-15</ns2:MeetingEndDate>
> </ns2:PlannerPreferredMeetingDate>
>
> .................................................................................
>
> The regex pattern I use is: <(.*)RfpOID>(.*)</(.*)RfpOID> to grape the
> rfpOID for this response due to the namesapce prex "ns2" changes sometime
> and the response of this api around big to 65k.
>
> The CPU will be eat quickly when I use 20 threads user load
>
>
> - *20 Threads* ( Jmeter thread eat 97% CPU)
>
>
>
> And the thread dump from Jmeter is saying mosto the Jmeter Thread is
> running for *Perl5Matcher*
> *
> "Before_getRfp 1-10" prio=6 tid=0x03067c00 nid=0x4874 runnable [0x04d8f000]
> java.lang.Thread.State: RUNNABLE
> at org.apache.oro.text.regex.Perl5Matcher.__match(Unknown Source)
> at org.apache.oro.text.regex.Perl5Matcher.__match(Unknown Source)
> at org.apache.oro.text.regex.Perl5Matcher.__tryExpression(Unknown
> Source)
> at org.apache.oro.text.regex.Perl5Matcher.__interpret(Unknown Source)
> at org.apache.oro.text.regex.Perl5Matcher.contains(Unknown Source)
> at
>
> org.apache.jmeter.extractor.RegexExtractor.matchStrings(RegexExtractor.java:234)
> at
>
> org.apache.jmeter.extractor.RegexExtractor.processMatches(RegexExtractor.java:219)
> at
> org.apache.jmeter.extractor.RegexExtractor.process(RegexExtractor.java:118)
> at
>
> org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:737)
> at
>
> org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:438)
> at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
> at java.lang.Thread.run(Unknown Source)*
>
> Also, the single thread load also will jump to 25% CPU utilization
>
>
> - *Single Thread* (Jmeter thread eat 25% CPU)
>
> After that, I did some tests to compare Perl5Matcher with other Java perl5
> regex lib ( I use jregex). Please check my code attached.
>
> Time for using org.apache.oro.text.regex.Perl5Matcher 3801(ms)
>
> Time for using jregex 13(ms)
> *
> *
> Thanks for reading so long but I'd like to know if we can user other regex
> lib for Jmeter.
>
> Vance*
> *
>