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

Emmanuel Lecharny commented on DIRMINA-934:
-------------------------------------------

There is still one thing that needs to be reviewed : the lock is acquired 
before the decoding is done, and released after the message has been processed. 
This is not the case in the existing code, where we just protect the decoderOut 
instance while decoding, which means some other thread might perfectly clear 
the queue qhile the current thread is expecting something to be present.

I think there is a major flaw in the way we process the decoding, but we are 
most certainly protected by the fact that we don't often use an executor in the 
chain, and especially an unordered thread executor.

The proposed fix not only save some CPU by removing the synchronized section, 
but also protect the code from more severe race conditions.

Btw, I think that we can get rid of the ConcurrentLinkedQueue in the 
AbstractProtocolDecoderOutput if we use this fix. I'll do that and run the test.

I would really appreciate that someone else review the patch and the 
consequences.


Many thanks !
                
> 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: ProtocolCodecFilterWithSemaphore.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 or grab it from here: 
> https://dl.dropbox.com/u/7316897/red5/drop/ProtocolCodecFilterWithSemaphore.diff

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to