[infinispan-dev] Adaptive marshaller buffer sizes - ISPN-1102

Dan Berindei dan.berindei at gmail.com
Mon May 23 12:50:03 EDT 2011


On Mon, May 23, 2011 at 7:20 PM, Bela Ban <bban at redhat.com> wrote:
>
>
> On 5/23/11 6:15 PM, Dan Berindei wrote:
>
>> I totally agree, combining adaptive size with buffer reuse would be
>> really cool. I imagine when passing the buffer to JGroups we'd still
>> make an arraycopy, but we'd get rid of a lot of arraycopy calls to
>> resize the buffer when the average object size is>  500 bytes. At the
>> same time, if a small percentage of the objects are much bigger than
>> the rest, we wouldn't reuse those huge buffers so we wouldn't waste
>> too much memory.
>
>
>  From my experience, reusing and syncing on a buffer will be slower than
> making a simple arraycopy. I used to reuse buffers in JGroups, but got
> better perf when I simply copied the buffer.

We wouldn't need any synchronization if we reused one buffer per thread ;-)

While working on optimizing the hotrod client I also thought about
reusing the buffer inside the marshaller and passing a copy to the
transport, but I didn't implement it because I wasn't sure how I could
reuse just the default size buffer and drop any buffers created with
bigger sizes.

> Plus the reservoir sampling's complexity is another source of bugs...
>

Adaptive buffer size can also help during the creation of the buffer:
if the value size is routinely > 5KB, in order to grow the buffer from
500 bytes to 5000 we'd have at least 3 arraycopy calls for each
marshall operation. With an estimated size of 4000 we'd have just one
arraycopy call.

But Sanne's suggestion of an externalizer method to suggest the size
may be even better.

> --
> Bela Ban
> Lead JGroups / Clustering Team
> JBoss
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev
>



More information about the infinispan-dev mailing list