[jboss-jira] [JBoss JIRA] (JGRP-2017) Optimize COMPRESS protocol by pooling / re-using byte array/buffer

Bela Ban (JIRA) issues at jboss.org
Tue Feb 23 02:23:00 EST 2016


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

Bela Ban commented on JGRP-2017:
--------------------------------

Hmm, there _is_ a superfluous copy in {{COMPRESS.down()}}: {{new_payload}} is unneeded as {{compressed_payload}} was already created and can be set in the message.
However, the problem is that if we reuse a send buffer, we need to copy the contents of it into a message as the message might get retransmitted (e.g. by {{NAKACK2}}) and buffer reuse might change the buffer's contents. Looks like we cannot prevent that 1 copy in the down and up direction...

> Optimize COMPRESS protocol by pooling / re-using byte array/buffer
> ------------------------------------------------------------------
>
>                 Key: JGRP-2017
>                 URL: https://issues.jboss.org/browse/JGRP-2017
>             Project: JGroups
>          Issue Type: Enhancement
>    Affects Versions: 3.4.5, 3.6.7
>         Environment: Wildfly 8.2.1.Final (JGroups 3.4.5)
>            Reporter: Mathieu Lachance
>            Assignee: Bela Ban
>             Fix For: 3.6.8, 4.0
>
>
> I'm currently working to minimize our application UDP bandwith usage by enabling the COMPRESS protocol in Wildfly 8.2.1.Final.
> Enabling the COMPRESS protocol works fine on that regards by reducing approximatly by 7x the amount of UDP traffic which is really neat.
> The thing is by enabling compression we are trading off increased cpu / memory usage for lowered network bandwith usage. In our case, we actually a notable increase of the cpu / memory usage due to increased usage of the garbage collector.
> When I had a look at the COMPRESS protocol implementation we see that both Deflator and Inflator are pooled and re-used (great) but not at the byte array level (not great).
> This compression pattern is very similar to GZip compression filter we can find in any recent Http spec implementors. In the Netty project for example, there's various compression protocol and/or utilities that are available and fine-tunable and they all have in common to re-use byte buffer and/or try to avoid byte arrays instantiation/copy at maximum.
> Here is some notable classes of the Netty implementation:
> https://github.com/netty/netty/blob/4.1/codec-http/src/main/java/io/netty/handler/codec/http/HttpContentCompressor.java 
> https://github.com/netty/netty/blob/4.1/codec/src/main/java/io/netty/handler/codec/compression/ZlibWrapper.java 
> https://github.com/netty/netty/blob/4.1/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java 
> https://github.com/netty/netty/blob/4.1/codec/src/main/java/io/netty/handler/codec/compression/JZlibEncoder.java 
> I think re-implementing something similar in JGroups would yield great benefits to the COMPRESS protocol. Maybe also, there's something that could be picked off right from the JBoss XNIO and/or the Undertow projects?
> Finally, I do not know also if we could add ergonomics at the same time to automatically determine the best number of Deflator and Inflator by keeping trace of the amount of time waited to pool one of them?
> Thanks,



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list