[jboss-jira] [JBoss JIRA] (JGRP-1773) TP$MyHandler.handleSingleMessage() makes an unnecessary copy of the buffer

Sanne Grinovero (JIRA) issues at jboss.org
Fri Jan 17 10:34:33 EST 2014


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

Sanne Grinovero commented on JGRP-1773:
---------------------------------------

[~pruivo] was also interested in this, and asked why we can't be clever in UDP's org.jgroups.protocols.UDP.PacketReceiver.run() 

Wouldn't it be nice to allocate only the receive buffer size of the minimal size possible?

I'd say it should not use a size larger than the IPv4/6 required size at least, but maybe we can even look into the header to understand how long the buffer for the copy needs to be?
                
> TP$MyHandler.handleSingleMessage() makes an unnecessary copy of the buffer
> --------------------------------------------------------------------------
>
>                 Key: JGRP-1773
>                 URL: https://issues.jboss.org/browse/JGRP-1773
>             Project: JGroups
>          Issue Type: Enhancement
>            Reporter: Bela Ban
>            Assignee: Bela Ban
>             Fix For: 3.5
>
>
> When a single message is received, we pass it to the thread pool for parsing, passing a copy of the byte array to the MyHandler runnable.
> The parsing then creates a new Message and calls readFrom(). This method reads the headers and then creates a payload buffer of the size read from the input stream, then copies {{size}} bytes from the input stream to the mesage's payload.
> This is an unneeded copy; as we already have a copy of the byte array, we only need to *reference* the byte array from the message and set the offset and length, saving us one copy of the buffer.

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


More information about the jboss-jira mailing list