[ 
https://issues.apache.org/jira/browse/WICKET-2875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12868729#action_12868729
 ] 

Stefan Fussenegger commented on WICKET-2875:
--------------------------------------------

Hi Igor, I just did some elementary performance testing with both Injector 
implementations. I simply used System.nanoTime() inside Injector.inject(object, 
factory) and crawled 2000 pages of my app using 8 concurrent threads (with 
client and server both on my quad core desktop). These are the results:

new implementation: crawled 2000 pages, spent 3.4 seconds injecting 1,571,294 
objects, 0.002 ms avg per injection, 1.7 ms avg per page
old implementation: crawled 2000 pages, spent 22.3 seconds injecting 1,559,287 
objects, 0.014 ms avg per injection, 11.1 ms avg per page

Looks like the new implementation is around 6 to 7 times faster while using 
less memory (reusing empty array), less synchronization (ClassMetaCache and 
during reflection) and causing less garbage (no unnecessary 
ConcurrentHashMaps). The difference should therefore get even bigger with 
higher concurrency and/or garbage collection involved (the later is most likely 
the reason why it appeared so often in my special case).

Seems pretty good to me.

Anything else I could do for you?

> Heavily Broken Caching in Injector
> ----------------------------------
>
>                 Key: WICKET-2875
>                 URL: https://issues.apache.org/jira/browse/WICKET-2875
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8
>         Environment: current trunk version
>            Reporter: Stefan Fussenegger
>            Assignee: Igor Vaynberg
>         Attachments: wicket-2875.patch
>
>
> The caching implementation in org.apache.wicket.injection.Injector is heavily 
> broken. for each (!) component, a ConcurrentHashMap is created and 
> findFields(..) get called. This happens as a new container is created for 
> every yet unknown class instead of yet unknown ClassLoaders.
> this is the erroneous code:
> // try cache
> ConcurrentHashMap<String, Field[]> container = 
> cache.get(clazz.getClassLoader());
> if (container != null)
> {
>       fields = container.get(clazz.getName());
> }
> if (fields == null)
> {
>       fields = findFields(clazz, factory);
>       // write to cache
>       container = new ConcurrentHashMap<String, Field[]>();
>       container.put(clazz.getName(), fields);
>       cache.put(clazz.getClassLoader(), container);
> }
> By the way: This bug was introduced with the fix of WICKET-625 in revision 
> 830070 dated 0ct 27, 2009

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to