You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Henryk Konsek (JIRA)" <ji...@apache.org> on 2012/06/26 13:19:44 UTC
[jira] [Created] (CAMEL-5398) Optimize String.replaceAll() to cache
Patterns where suitable
Henryk Konsek created CAMEL-5398:
------------------------------------
Summary: Optimize String.replaceAll() to cache Patterns where suitable
Key: CAMEL-5398
URL: https://issues.apache.org/jira/browse/CAMEL-5398
Project: Camel
Issue Type: Improvement
Reporter: Henryk Konsek
Assignee: Henryk Konsek
Fix For: 2.11
Inspired by issue [1] regarding performance of JMS headers, I performed a little search in IDE and found out that there's pretty much not optimized String.replaceAll() calls.
I think it will be good to search the code base for such calls again and replace them with references to the static pre-compiled java.util.regex.Patterns. Of course if such action makes sense (like in StringHelper#removeQuotes()).
[1] https://issues.apache.org/jira/browse/CAMEL-5396
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Reopened] (CAMEL-5398) Optimize String.replaceAll() to
cache Patterns where suitable
Posted by "Henryk Konsek (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henryk Konsek reopened CAMEL-5398:
----------------------------------
After playing more with CAMEL-5396, I come with conclusion that we could benefit from Pattern.compile() optimization in some cases.
I'm reopening this issue - I'll take a closer look at each individual case.
> Optimize String.replaceAll() to cache Patterns where suitable
> -------------------------------------------------------------
>
> Key: CAMEL-5398
> URL: https://issues.apache.org/jira/browse/CAMEL-5398
> Project: Camel
> Issue Type: Improvement
> Reporter: Henryk Konsek
> Assignee: Henryk Konsek
> Fix For: 2.11
>
>
> Inspired by issue [1] regarding performance of JMS headers, I performed a little search in IDE and found out that there's pretty much not optimized String.replaceAll() calls.
> I think it will be good to search the code base for such calls again and replace them with references to the static pre-compiled java.util.regex.Patterns. Of course if such action makes sense (like in StringHelper#removeQuotes()).
> [1] https://issues.apache.org/jira/browse/CAMEL-5396
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CAMEL-5398) Optimize String.replaceAll() to
cache Patterns where suitable
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401303#comment-13401303 ]
Claus Ibsen commented on CAMEL-5398:
------------------------------------
Frankly the compiler should IMHO be able to optimize this code itself, as if the input to the replace methods is a fixed string, then its not changed at runtime. And thus the compiler could take advantage of that.
Could you maybe do a test to see if you can measure and speed difference?
> Optimize String.replaceAll() to cache Patterns where suitable
> -------------------------------------------------------------
>
> Key: CAMEL-5398
> URL: https://issues.apache.org/jira/browse/CAMEL-5398
> Project: Camel
> Issue Type: Improvement
> Reporter: Henryk Konsek
> Assignee: Henryk Konsek
> Fix For: 2.11
>
>
> Inspired by issue [1] regarding performance of JMS headers, I performed a little search in IDE and found out that there's pretty much not optimized String.replaceAll() calls.
> I think it will be good to search the code base for such calls again and replace them with references to the static pre-compiled java.util.regex.Patterns. Of course if such action makes sense (like in StringHelper#removeQuotes()).
> [1] https://issues.apache.org/jira/browse/CAMEL-5396
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (CAMEL-5398) Optimize String.replaceAll() to
cache Patterns where suitable
Posted by "Henryk Konsek (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401332#comment-13401332 ]
Henryk Konsek commented on CAMEL-5398:
--------------------------------------
Actually executing the loop below:
for(int i = 0; i < 1000000; i++) {
Pattern.compile(RandomStringUtils.randomAlphabetic(100));
}
...takes ~10 seconds.
I've never benchmarked the famous Pattern.compile() efficiency but If I can parse million of random 100-character long alphanumeric patterns in 10 seconds (on my 700$ laptop), then I screw Pattern precompilation for the rest of my life :) .
> Optimize String.replaceAll() to cache Patterns where suitable
> -------------------------------------------------------------
>
> Key: CAMEL-5398
> URL: https://issues.apache.org/jira/browse/CAMEL-5398
> Project: Camel
> Issue Type: Improvement
> Reporter: Henryk Konsek
> Assignee: Henryk Konsek
> Fix For: 2.11
>
>
> Inspired by issue [1] regarding performance of JMS headers, I performed a little search in IDE and found out that there's pretty much not optimized String.replaceAll() calls.
> I think it will be good to search the code base for such calls again and replace them with references to the static pre-compiled java.util.regex.Patterns. Of course if such action makes sense (like in StringHelper#removeQuotes()).
> [1] https://issues.apache.org/jira/browse/CAMEL-5396
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (CAMEL-5398) Optimize String.replaceAll() to
cache Patterns where suitable
Posted by "Henryk Konsek (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henryk Konsek resolved CAMEL-5398.
----------------------------------
Resolution: Fixed
> Optimize String.replaceAll() to cache Patterns where suitable
> -------------------------------------------------------------
>
> Key: CAMEL-5398
> URL: https://issues.apache.org/jira/browse/CAMEL-5398
> Project: Camel
> Issue Type: Improvement
> Reporter: Henryk Konsek
> Assignee: Henryk Konsek
> Fix For: 2.11
>
>
> Inspired by issue [1] regarding performance of JMS headers, I performed a little search in IDE and found out that there's pretty much not optimized String.replaceAll() calls.
> I think it will be good to search the code base for such calls again and replace them with references to the static pre-compiled java.util.regex.Patterns. Of course if such action makes sense (like in StringHelper#removeQuotes()).
> [1] https://issues.apache.org/jira/browse/CAMEL-5396
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Resolved] (CAMEL-5398) Optimize String.replaceAll() to
cache Patterns where suitable
Posted by "Henryk Konsek (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henryk Konsek resolved CAMEL-5398.
----------------------------------
Resolution: Won't Fix
> Optimize String.replaceAll() to cache Patterns where suitable
> -------------------------------------------------------------
>
> Key: CAMEL-5398
> URL: https://issues.apache.org/jira/browse/CAMEL-5398
> Project: Camel
> Issue Type: Improvement
> Reporter: Henryk Konsek
> Assignee: Henryk Konsek
> Fix For: 2.11
>
>
> Inspired by issue [1] regarding performance of JMS headers, I performed a little search in IDE and found out that there's pretty much not optimized String.replaceAll() calls.
> I think it will be good to search the code base for such calls again and replace them with references to the static pre-compiled java.util.regex.Patterns. Of course if such action makes sense (like in StringHelper#removeQuotes()).
> [1] https://issues.apache.org/jira/browse/CAMEL-5396
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Reopened] (CAMEL-5398) Optimize String.replaceAll() to
cache Patterns where suitable
Posted by "Henryk Konsek (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CAMEL-5398?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henryk Konsek reopened CAMEL-5398:
----------------------------------
> Optimize String.replaceAll() to cache Patterns where suitable
> -------------------------------------------------------------
>
> Key: CAMEL-5398
> URL: https://issues.apache.org/jira/browse/CAMEL-5398
> Project: Camel
> Issue Type: Improvement
> Reporter: Henryk Konsek
> Assignee: Henryk Konsek
> Fix For: 2.11
>
>
> Inspired by issue [1] regarding performance of JMS headers, I performed a little search in IDE and found out that there's pretty much not optimized String.replaceAll() calls.
> I think it will be good to search the code base for such calls again and replace them with references to the static pre-compiled java.util.regex.Patterns. Of course if such action makes sense (like in StringHelper#removeQuotes()).
> [1] https://issues.apache.org/jira/browse/CAMEL-5396
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira