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.
Plus the reservoir sampling's complexity is another source of bugs...
--
Bela Ban
Lead JGroups / Clustering Team
JBoss