|Re: [equinox-dev] Service Lookup by GUID very Slow - the Framework Scalability|
|* No, services are not
created lazily by default. You are creating the services yourself in
your code sample, i.e., the 'serviceObject' variable.|
There are some frameworks such as Declarative Services that create service instances lazily, however the creation of the service (and therefore the associated cost) would not be triggered by merely calling getServiceReferences(). It would be triggered by calling getService() on one of the ServiceReference objects.
* By creating a ServiceTracker, you can be notified synchronously as each service is registered. You could then very cheaply extract the ID property from each service and store it in a ConcurrentHashMap for later reference.
I'm pretty sure that the poor performance of your example is due to the fact that the framework is forced to evaluate the filter _expression_ "(ID=x)" against every entry in the registry. You don't even allow it to return when it finds the first match, because you have called getServiceReferences(), plural, so it must find all of the matches not just the first one. If you called getServiceReference() then the search time would be halved, on aggregate.