camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henryk Konsek (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CAMEL-5396) Improve performance of DefaultJmsKeyFormatStrategy
Date Tue, 26 Jun 2012 10:57:44 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-5396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13401291#comment-13401291
] 

Henryk Konsek edited comment on CAMEL-5396 at 6/26/12 10:57 AM:
----------------------------------------------------------------

I've added a patch (CAMEL-5396.patch) that caches java.util.regex.Pattern as static members
and then uses Pattern.mattcher.replaceAll() on them. This will save us compilation of the
RegEx patterns.

There is no dependency for Apache Commons now.

I've removed the map cache however. We cannot just store all processed keys in maps. In case
of long running routers this will lead to memory leaks. The option will be to use some LRU
cache (from Commons[1] or Guava[2]). However if we do not want to have dependendency to Commons
or Guava in JMS module, we should consider providing some kind of general cache service abstraction
for Camel that could be retrieved from the Camel registry.

[1] http://commons.apache.org/collections/apidocs/org/apache/commons/collections/map/LRUMap.html
[2] http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/Cache.html
                
      was (Author: hekonsek):
    I've added a patch that caches java.util.regex.Pattern as static members and then uses
Pattern.mattcher.replaceAll() on them. This will save us compilation of the RegEx patterns.

There is no dependency for Apache Commons now.

I've removed the map cache however. We cannot just store all processed keys in maps. In case
of long running routers this will lead to memory leaks. The option will be to use some LRU
cache (from Commons[1] or Guava[2]). However if we do not want to have dependendency to Commons
or Guava in JMS module, we should consider providing some kind of general cache service abstraction
for Camel that could be retrieved from the Camel registry.

[1] http://commons.apache.org/collections/apidocs/org/apache/commons/collections/map/LRUMap.html
[2] http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/cache/Cache.html
                  
> Improve performance of DefaultJmsKeyFormatStrategy
> --------------------------------------------------
>
>                 Key: CAMEL-5396
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5396
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jms
>    Affects Versions: 2.9.2
>            Reporter: Mark Hillary
>            Assignee: Henryk Konsek
>              Labels: patch, performance
>         Attachments: CAMEL-5396.patch, default-jms-key-strat.diff
>
>
> The current default implementation uses String.replace/replaceAll to escape the illegal
characters in the header key. This is unfortunate because replace/replaceAll are implemented
in terms of regular expressions which makes the escaping quite costly for something that is
executed for every single message. Also it's quite likely that the headers will be identical
for every single message that's published via JMS. 
> The attached patch makes two changes;
> * Use Commons Lang StringUtil.replaceEach which using a StringBuilder internally to do
the replacement. This adds a dependency on Commons Lang.
> * Cache the output of StringUtil.replaceEach in a ConcurrentHashMap. This could be moved
to a separate class if caching every key is a concern. Or this could be changed to use an
LRUCache

--
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

        

Mime
View raw message