[ 
https://issues.apache.org/jira/browse/DIRMINA-934?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Emmanuel Lecharny reopened DIRMINA-934:
---------------------------------------

Actually, this was a bad idea...

The pb with the semaphore is that it creates a lock that is global for an 
instance of the codec filter. If one don't crate as many filter as there are 
sessions, then this will create a bottleneck.

The synchronized(decoder) is also a problem though : it creates a bottleneck on 
the decoder, which might not be instanciated for each session, but shared. In 
this case, we have a serialization of the decoding across all the server, which 
is even worse (and that was what this patch was trying to solve, AFAICT).

The right solution would instead be to synchronized on the session, because 
there is no way that could create a bottleneck :
- each session will be able to use the decoder at will, in a serial way
- a session won't lock another session during a decoding

A side remark : on TCP, there is no reason we should have an executor being 
present *before* the decoder, because that would forbid the decoding of a split 
messages. On UDP, there is no such problem, so we *may* want later to remove 
the synchronized section when we are on UDP.

> Replace synchronized with a Semaphore for better performance
> ------------------------------------------------------------
>
>                 Key: DIRMINA-934
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-934
>             Project: MINA
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 2.0.7, 2.0.8
>         Environment: Window 8 Pro x64, JDK 7
>            Reporter: Paul Gregoire
>              Labels: patch
>             Fix For: 2.0.8
>
>         Attachments: ProtocolCodecFilterWithSemaphoreAndMore.diff
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Replacing the synchronized block with a Semaphore in the ProtocolCodecFilter 
> provides a lot of benefit in terms of locking and also reduces CPU 
> utilization. See attached git diff.



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

Reply via email to