You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Ian Boston <ie...@tfd.co.uk> on 2009/11/06 19:08:23 UTC

New Map base ResourceProviderEntry

I recently committed a change to the core ResourceProviderEntry that  
stores all the Providers that resolve Resources in Sling. These  
include the standard JcrResourceProvider that resolve Node resources  
in the first phase of request processing (URL->Node) and  
ServletResourceProviders that resolve the Servlet in the second phase  
of request processing (ie which Servlet handles this request for this  
resource given the URL).

I notices when doing some debugging that the original version was  
using loop searches to locate Resources, not so much of a problem in  
the first phase since this only happens once, but more of a problem in  
the second phase when a search is performed over multiple paths to  
locate the best Servlet match. In short the new version  
ResourceProviderEntry2 builds ResourceProvidersEntry2's into a tree of  
maps which can be walked to locate the correct ResourceProvider.  
Scalability as the number of ResourceProviders should be proportional  
to the depth of tree, rather than the number of ResourceProviders.

This morning I have done some profiling and found for the integration  
tests, which exercise this area of code the total time spent in  
ResourceProviderEntry.getResource(...) is 14309ms whereas the total  
time spent in RescoureProviderEntry2.getResource(...) is 9945ms,  
(~30%) This just shows the effect of the change at a small number  
(about 15) ResourceProviders, and the difference should become more  
dramatic with more ResourceProviders.

In addition to speeding this area of the code up,  
ResourceProviderEntry2 now supports the registration of multiple  
ResourceProviders at any point in the tree. These are consulted in  
turn for a match. The order in which they are consulted is dependent  
on the natural sort order of the ServiceReference. This means that you  
can now bind ResourceProviders to something other than sub path, like  
node property.

If you notice any strange behavior with this update, that the  
integration tests have not caught, please shout. There are no changes  
to any public API's.

Ian



Re: New Map base ResourceProviderEntry

Posted by Ian Boston <ie...@tfd.co.uk>.
On 6 Nov 2009, at 10:18, Carsten Ziegeler wrote:

> That sounds great. Thanks, Ian!
>
> I just have one minor comment :)
>
> Can we drop the "2" in the class names?


Yes, sure, it was a device to know exactly which one was being used  
during dev.
Ian

>
> Carsten
>
> Ian Boston wrote:
>> I recently committed a change to the core ResourceProviderEntry that
>> stores all the Providers that resolve Resources in Sling. These  
>> include
>> the standard JcrResourceProvider that resolve Node resources in the
>> first phase of request processing (URL->Node) and
>> ServletResourceProviders that resolve the Servlet in the second  
>> phase of
>> request processing (ie which Servlet handles this request for this
>> resource given the URL).
>>
>> I notices when doing some debugging that the original version was  
>> using
>> loop searches to locate Resources, not so much of a problem in the  
>> first
>> phase since this only happens once, but more of a problem in the  
>> second
>> phase when a search is performed over multiple paths to locate the  
>> best
>> Servlet match. In short the new version ResourceProviderEntry2 builds
>> ResourceProvidersEntry2's into a tree of maps which can be walked to
>> locate the correct ResourceProvider. Scalability as the number of
>> ResourceProviders should be proportional to the depth of tree, rather
>> than the number of ResourceProviders.
>>
>> This morning I have done some profiling and found for the integration
>> tests, which exercise this area of code the total time spent in
>> ResourceProviderEntry.getResource(...) is 14309ms whereas the total  
>> time
>> spent in RescoureProviderEntry2.getResource(...) is 9945ms, (~30%)  
>> This
>> just shows the effect of the change at a small number (about 15)
>> ResourceProviders, and the difference should become more dramatic  
>> with
>> more ResourceProviders.
>>
>> In addition to speeding this area of the code up,  
>> ResourceProviderEntry2
>> now supports the registration of multiple ResourceProviders at any  
>> point
>> in the tree. These are consulted in turn for a match. The order in  
>> which
>> they are consulted is dependent on the natural sort order of the
>> ServiceReference. This means that you can now bind  
>> ResourceProviders to
>> something other than sub path, like node property.
>>
>> If you notice any strange behavior with this update, that the
>> integration tests have not caught, please shout. There are no  
>> changes to
>> any public API's.
>>
>> Ian
>>
>>
>>
>
>
> -- 
> Carsten Ziegeler
> cziegeler@apache.org


Re: New Map base ResourceProviderEntry

Posted by Carsten Ziegeler <cz...@apache.org>.
That sounds great. Thanks, Ian!

I just have one minor comment :)

Can we drop the "2" in the class names?

Carsten

Ian Boston wrote:
> I recently committed a change to the core ResourceProviderEntry that
> stores all the Providers that resolve Resources in Sling. These include
> the standard JcrResourceProvider that resolve Node resources in the
> first phase of request processing (URL->Node) and
> ServletResourceProviders that resolve the Servlet in the second phase of
> request processing (ie which Servlet handles this request for this
> resource given the URL).
> 
> I notices when doing some debugging that the original version was using
> loop searches to locate Resources, not so much of a problem in the first
> phase since this only happens once, but more of a problem in the second
> phase when a search is performed over multiple paths to locate the best
> Servlet match. In short the new version ResourceProviderEntry2 builds
> ResourceProvidersEntry2's into a tree of maps which can be walked to
> locate the correct ResourceProvider. Scalability as the number of
> ResourceProviders should be proportional to the depth of tree, rather
> than the number of ResourceProviders.
> 
> This morning I have done some profiling and found for the integration
> tests, which exercise this area of code the total time spent in
> ResourceProviderEntry.getResource(...) is 14309ms whereas the total time
> spent in RescoureProviderEntry2.getResource(...) is 9945ms, (~30%) This
> just shows the effect of the change at a small number (about 15)
> ResourceProviders, and the difference should become more dramatic with
> more ResourceProviders.
> 
> In addition to speeding this area of the code up, ResourceProviderEntry2
> now supports the registration of multiple ResourceProviders at any point
> in the tree. These are consulted in turn for a match. The order in which
> they are consulted is dependent on the natural sort order of the
> ServiceReference. This means that you can now bind ResourceProviders to
> something other than sub path, like node property.
> 
> If you notice any strange behavior with this update, that the
> integration tests have not caught, please shout. There are no changes to
> any public API's.
> 
> Ian
> 
> 
> 


-- 
Carsten Ziegeler
cziegeler@apache.org

Re: New Map base ResourceProviderEntry

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Ian,

Excellent Job !

Thanks for the heads up information.


Regards
Felix

Ian Boston schrieb:
> I recently committed a change to the core ResourceProviderEntry that
> stores all the Providers that resolve Resources in Sling. These include
> the standard JcrResourceProvider that resolve Node resources in the
> first phase of request processing (URL->Node) and
> ServletResourceProviders that resolve the Servlet in the second phase of
> request processing (ie which Servlet handles this request for this
> resource given the URL).
> 
> I notices when doing some debugging that the original version was using
> loop searches to locate Resources, not so much of a problem in the first
> phase since this only happens once, but more of a problem in the second
> phase when a search is performed over multiple paths to locate the best
> Servlet match. In short the new version ResourceProviderEntry2 builds
> ResourceProvidersEntry2's into a tree of maps which can be walked to
> locate the correct ResourceProvider. Scalability as the number of
> ResourceProviders should be proportional to the depth of tree, rather
> than the number of ResourceProviders.
> 
> This morning I have done some profiling and found for the integration
> tests, which exercise this area of code the total time spent in
> ResourceProviderEntry.getResource(...) is 14309ms whereas the total time
> spent in RescoureProviderEntry2.getResource(...) is 9945ms, (~30%) This
> just shows the effect of the change at a small number (about 15)
> ResourceProviders, and the difference should become more dramatic with
> more ResourceProviders.
> 
> In addition to speeding this area of the code up, ResourceProviderEntry2
> now supports the registration of multiple ResourceProviders at any point
> in the tree. These are consulted in turn for a match. The order in which
> they are consulted is dependent on the natural sort order of the
> ServiceReference. This means that you can now bind ResourceProviders to
> something other than sub path, like node property.
> 
> If you notice any strange behavior with this update, that the
> integration tests have not caught, please shout. There are no changes to
> any public API's.
> 
> Ian
> 
> 
>