[jboss-jira] [JBoss JIRA] (JGRP-1989) Bundlers: reuse send buffer when transport == sync.

Bela Ban (JIRA) issues at jboss.org
Mon Dec 14 07:16:00 EST 2015


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

Bela Ban edited comment on JGRP-1989 at 12/14/15 7:15 AM:
----------------------------------------------------------

OK, so on the send side:
* Messages always go through the bundler, either as message batches or single messages (optimization for batch of 1)
** For bundled messages, a {{ByteArrayDataOutputStream}} with a capacity of {{max_bundle_size + MSG_OVERHEAD}} (the latter is space for version and flags) is created. The size of the output stream won't increase as no message bundle will ever be bigger than {{max_bundle_size}}.
** This buffer is reused for all messages bundles
** This is possible because - in all bundlers - a single thread sends the queued-up messages
* Single messages (marked as {{DONT_BUNDLE | OOB}}) will cause creation of a new buffer every single time
** This should not be a big issue as this combination is used very rarely
* There is no need for buffer pools in this case; a single buffer (in {{ByteArrayDataOutputStream}}) suffices


was (Author: belaban):
OK, so on the send side:
* Messages always go through the bundler, either as message batches or single messages (optimization for batch of 1)
** For bundled messages, a {{ByteArrayDataOutputStream}} with a capacity of {{max_bundle_size + MSG_OVERHEAD}} (the latter is space for version and flags) is created. The size of the output stream won't increase as no message bundle will ever be bigger than {{max_bundle_size}}
* Single messages (marked as {{DONT_BUNDLE | OOB}}) will cause creation of a new buffer every single time
** This should not be a big issue as this combination is used very rarely
* There is no need for buffer pools in this case; a single buffer (in {{ByteArrayDataOutputStream}}) suffices

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


More information about the jboss-jira mailing list