camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Arkadi Shishlov (JIRA)" <>
Subject [jira] [Updated] (CAMEL-4009) Fast @Converter loading in uber-jar
Date Sun, 29 May 2011 14:32:47 GMT


Arkadi Shishlov updated CAMEL-4009:

    Attachment: apache-camel-r1128875-fast-TypeConverter-loading-in-uber-jar-try2.diff

After thinking a little bit I implemented in-memory cache of jar entries names via SoftRefence
in loadImplementationsInJar(). Please see attached path \-try2.
The memory will be release by GC eventually. I'm not sure the PackageScanClassResolver meant
to be thread-safe or not - current usage is single threaded, but anyway, memory ordering is
protected by volatile and hash is synchronized to be on the safe side.
The peformance is good - same 2 seconds as with previous patch vs 15 sec of original approach.

> Fast @Converter loading in uber-jar
> -----------------------------------
>                 Key: CAMEL-4009
>                 URL:
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 2.7.0
>            Reporter: Arkadi Shishlov
>            Priority: Minor
>              Labels: uber-jar
>             Fix For: Future
>         Attachments: apache-camel-r1127037-fast-TypeConverter-loading-in-uber-jar.diff,
> Currently, the @Converter converters are loaded as follows
> {noformat}
> for package in TypeConverter meta-inf resource
>   get package url from classloader
>   if url is jar
>     for entries in jar
>       if entry match package
>         check annotation
> {noformat}
> This is very inefficient approach when application is packaged into uber-jar as expensive
iteration is performed multiple times over same jar.
> The attached patch changes loop into:
> {noformat}
> for package in TypeConverter meta-inf resource
>   get package url from classloader
>   create map url -> package names
>   for url in distinct url
>     if jar
>       for entries in jar
>         for package in packages
>           if entry match package
>             check annotation
> {noformat}
> With this patch I was able to cut startup time significantly from 15sec spent on @Converter-s
load to 2sec on 45MB 29k entries uber-jar.
> I understand that the solution is not pretty but resolves a very practical problem. Let
me know if you want me to polish it and update the javadoc.

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message