[jboss-jira] [JBoss JIRA] (JGRP-1991) TCP_NIO2: copy on demand
Bela Ban (JIRA)
issues at jboss.org
Thu Dec 3 11:18:00 EST 2015
[ https://issues.jboss.org/browse/JGRP-1991?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13136783#comment-13136783 ]
Bela Ban commented on JGRP-1991:
--------------------------------
When using copying (a user might disable copying altogether if they pass copies to the write() anyway), we need to know which buffers have been copied yet, and which ones haven't. Since we're writing buffers from left to right (and thus copy from left to right, too), we could use a marker {{last_copied}} which is the index of the last copied buffer. All buffer after that index have not yet been copied. The following transitions can happen:
* The contents of the buffers are moved to the left -> the marker moves with the data, possibly to the first index
* We add a buffer -> marker stays in place
* We write a few buffers -> the marker moves just beyond the last _successfully_ written buffer
* A partial write occurs -> copy *all* buffers after the last successful write, up to the end of the buffer list
Whether or not to copy may also be a field of {{WriteBuffers}}.
> TCP_NIO2: copy on demand
> ------------------------
>
> Key: JGRP-1991
> URL: https://issues.jboss.org/browse/JGRP-1991
> Project: JGroups
> Issue Type: Enhancement
> Reporter: Bela Ban
> Assignee: Bela Ban
> Fix For: 3.6.7
>
>
> When TCP_NIO2 writes data, we always pass a copy of data of it, because of JGRP-1961 [1].
> However, if we copied the data only on a *partial write* (full writes don't need a copy), then we could always pass data from reused buffers down to the transport.
> Example: we want to write 3 buffers of 100, 200 and 700 bytes in a gathering write (the buffers are allocated from reusable byte[] arrays).
> If the write returns 1000, we know that all 3 buffers have been written and there is no need to copy any of the buffers. However, if only 500 bytes were written, then we can trash the first 2 buffers, but need to make a copy of the 3rd buffer in range [201 .. 700].
> This allows the sender to reuse previously allocated buffers, as all transports (UDP, TCP, TCP_NIO2) now guarantee that, on return of the send(), either the data was written completely, or a copy was made.
> [1] https://issues.jboss.org/browse/JGRP-1961
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list