[
https://issues.jboss.org/browse/JGRP-1989?page=com.atlassian.jira.plugin....
]
Bela Ban edited comment on JGRP-1989 at 12/3/15 4:51 AM:
---------------------------------------------------------
Another alternative is to always send the reusable buffer and copy at the {{TCP_NIO2}}
level *if needed*. For example, if a write of 1000 bytes succeeds, then we know that 1000
bytes have been written and the buffer can get reused.
If the write returns rc=800, then we know that we still need to write the final 200 bytes.
In this case, we could *copy* the bytes in range {{buf[801..1000]}}. I assume that a TCP
write would succeed in most cases, so this would not do a lot of copying.
Downside: an NIO write is done deep inside JGroups NIO ({{NioConnection}}), so we'd
have to let this class somehow know whether or not to copy data. For instance, if a user
always provides copied data in the first place, there'd be no need o copy at all.
was (Author: belaban):
Another alternative is to always send the reusable buffer and copy at the {{TCP_NIO2}}
level *if needed*. For example, if a write of 1000 bytes succeeds than we know that 1000
bytes have been written and the buffer can get reused.
If the write returns rc=800, then we know that we still need to write the final 200 bytes.
In this case, we could *copy* the bytes in range {{buf[801..1000]}}. I assume that a TCP
write would succeed in most cases, so this would not do a lot of copying.
Downside: an NIO write is done deep inside JGroups NIO ({{NioConnection}}), so we'd
have to let this class somehow know whether or not to copy data. For instance, if a user
always provides copied data in the first place, there'd be no need o copy at all.
Bundlers: reuse send buffer when transport == sync.
---------------------------------------------------
Key: JGRP-1989
URL:
https://issues.jboss.org/browse/JGRP-1989
Project: JGroups
Issue Type: Enhancement
Reporter: Bela Ban
Assignee: Bela Ban
Fix For: 3.6.7
With the addition of {{TCP_NIO2}}, all bundlers now create new send buffers for every
message (or message list). This generates a lot of memory allocations, perhaps it is
better to revert this change for *synchronous transports* such as {{UDP}} and {{TCP}}, and
still create new buffers for *asynchronous transports* such as {{TCP_NIO2}}.
Synchronous transports guarantee a message has been put on the wire when {{TP.send()}}
returns, whereas asynchronous transports may only have completed a partial write (so we
cannot reuse the buffer).
The code in the bundler should check for this, and copy if async or not copy if sync.
Whether or not a transport is sync is determined by a new abstract method that needs to
be overridden by every transport.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)