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

Don Brown commented on FELIX-1746:
----------------------------------

I applied your fix, re-ran JIRA startup, and saw the contention go away.  
However, JIRA startup is still really simple case in service lookup, and I'm 
concerned that even the most simple benchmark looking at service lookup would 
show it again.

As Jed pointed out, there is no need for a lock here.  Your patch causes on 
every read two locks and two copies.  A copy-on-write map would cause one copy 
on the registering of a service, then lock and copy-free access.  Furthermore, 
there are probably other potential cases where a COW map would help, as I 
noticed Felix goes a bit crazy with the synchronization... :)

> Eliminate contention on ServiceRegistry.getServiceReferences(String, Filter)
> ----------------------------------------------------------------------------
>
>                 Key: FELIX-1746
>                 URL: https://issues.apache.org/jira/browse/FELIX-1746
>             Project: Felix
>          Issue Type: Improvement
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Jed Wesley-Smith
>            Assignee: Karl Pauls
>         Attachments: blocked-threads.gif.jpg, FELIX-1746-alt.patch, 
> FELIX-1746-alt2.patch, FELIX-1746.patch
>
>
> Performance testing has shown that there is significant contention on the 
> ServiceRegistry object's monitor during startup. This is caused by Spring DM 
> making lots of calls to the synchronized method 
> ServiceRegistry.getServiceReferences(String, Filter). This method is 
> synchronized in order to protect the m_serviceRegsMap HashMap, but the method 
> does a lot more work than simply accessing the map.
> Propose changing the ServiceRegistry to use a thread-safe Map implementation 
> that does not require external synchronization, in particular a 
> CopyOnWriteMap. I will add a patch that includes a CopyOnWriteMap 
> implementation.

-- 
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