[jboss-jira] [JBoss JIRA] Commented: (JGRP-816) TP: avoid copying when receiving data

Bela Ban (JIRA) jira-events at lists.jboss.org
Mon Sep 22 07:55:21 EDT 2008


    [ https://jira.jboss.org/jira/browse/JGRP-816?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12430590#action_12430590 ] 

Bela Ban commented on JGRP-816:
-------------------------------

Note that the block is the lack of NIO support for MulticastSocket; Socket and ServerSocket (TCP) are supported. So maybe we should add some code to check for the JDK version and use NIO for MulticastSockets if available, or else fall back to pre-JDK 7 code... ?

> TP: avoid copying when receiving data
> -------------------------------------
>
>                 Key: JGRP-816
>                 URL: https://jira.jboss.org/jira/browse/JGRP-816
>             Project: JGroups
>          Issue Type: Feature Request
>            Reporter: Bela Ban
>            Assignee: Bela Ban
>             Fix For: 2.8
>
>
> Currently, we receive data into a byte[] buffer, e.g. from DatagramSocket.receive(), but then have to COPY buffer when passing it to a worker from the thread pool. The copy is needed because the next DatargamSocket.receive() will overwrite the contents of buffer, and if the worker thread is still unmarshalling the data from the buffer, it might read corrupt contents.
> To overcome this, investigate the following:
> - Every worker thread has it own buffer
> - When the thread has been idle for N seconds and is removed from the pool, that buffer will be discarded
> - We create DatagramChannels from the socket(s) (DatagramSocket, MulticastSocket or Socket)
> - A selector is called when new data is available on the socket
> - The key returned by the selector points to the right channel
> - We pass the channel to a thread pool worker thread and continue with the select() loop
> - The worker then reads the data into its own buffer, unmarshalls it and passed it up the stack
> ==> No copy of the buffer is required as the thread's buffer is available until the message has been processed (usually until message unmarshalling)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list