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

Felix Meschberger commented on FELIX-4692:
------------------------------------------

Digging a bit deeper, I found the following opportunities for improvements:

# In the {{CapabilitySet.match(Set<> caps, SimpleFilter sf)}} method on line 
239 the {{matches.retainAll(caps)}} call is guarded by an {{if (caps != 
m_capSet)}}
# The {{ServiceRegistry.getServiceReferences(String className, SimpleFilter 
filter)}} method returns the set from the {{CapabilitySet.match(SimplerFilter, 
boolean)}} method directly without copying that into an ArrayList. This 
requires a slight adaption in the {{Felix.getServiceReferences(BundleImpl, 
String, String, boolean)}} method.
# Using a {{SimpleFilter.MATCH_ALL}} filter instead of a filter which checks 
for the objectclass property presence.

This last change has a drammatic impact in our use case, because the presence 
checks caused lots of "useless" property access because the objectclasses 
property is always present for services and hence just simply matching all 
services is correct. The reason for this impact is that we leverage the Aries 
JMX bundles which do repeated {{BundleContext.getAllServiceReferences(null, 
null)}} calls (maybe worth investigating on another route).

With these three changes I come close to the improvements compared to attached 
patch [^FELIX-4692.diff] but they have a much lower impact. So I will create a 
new patch with these changes.

> Improve Service access time
> ---------------------------
>
>                 Key: FELIX-4692
>                 URL: https://issues.apache.org/jira/browse/FELIX-4692
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: framework-4.4.1
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: framework-4.6.0
>
>         Attachments: FELIX-4692.diff
>
>
> Currently the ServiceRegistry takes roughly 1ms to access a single service. 
> In a reasonably large system, this may over time consume considerable time.
> For example in our inhouse system sporting roughly 5000 services with 15'000 
> service accesses during startup, these accesses acount for almost 15 seconds 
> or roughly 25-30% of the total startup time.
> Internally all accesses to services are handled with a Filter even if the 
> service is simply retrieved with the service name without a filter. This 
> causes a considerable overhead.
> A simple improvement is to keep services not only in a global Capabitliy Set 
> accessible through generic filters but also keep such a set for each 
> registered service name.
> The measured improvement of this change is substantial: accessing these 
> 15'000 services now only takes roughly 3 seconds or 0.2 ms per service or 5 
> times faster.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to