Repository: cassandra Updated Branches: refs/heads/trunk c253f0806 -> 578c85dc7
Cleanup byte buffer recycling in DataOutputBuffer after Netty upgrade. Patch by Alex Petrov; reviewed by Jake Luciani for CASSANDRA-11937 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/578c85dc Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/578c85dc Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/578c85dc Branch: refs/heads/trunk Commit: 578c85dc74522668e5c1e89119d25117cba5abf4 Parents: c253f08 Author: Alex Petrov <oleksandr.pet...@gmail.com> Authored: Wed Jun 22 15:29:24 2016 +0200 Committer: T Jake Luciani <j...@apache.org> Committed: Fri Jun 24 10:44:23 2016 -0400 ---------------------------------------------------------------------- .../apache/cassandra/io/util/DataOutputBuffer.java | 12 +++++------- src/java/org/apache/cassandra/utils/btree/BTree.java | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/578c85dc/src/java/org/apache/cassandra/io/util/DataOutputBuffer.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/io/util/DataOutputBuffer.java b/src/java/org/apache/cassandra/io/util/DataOutputBuffer.java index 2091ed0..f08b48f 100644 --- a/src/java/org/apache/cassandra/io/util/DataOutputBuffer.java +++ b/src/java/org/apache/cassandra/io/util/DataOutputBuffer.java @@ -87,13 +87,11 @@ public class DataOutputBuffer extends BufferedDataOutputStreamPlus { assert handle != null; - // Avoid throwing away instances that are too large, trim large buffers to default size instead. - // See CASSANDRA-11838 for details. - if (buffer().capacity() > MAX_RECYCLE_BUFFER_SIZE) - buffer = ByteBuffer.allocate(DEFAULT_INITIAL_BUFFER_SIZE); - - buffer.rewind(); - RECYCLER.recycle(this, handle); + if (buffer().capacity() <= MAX_RECYCLE_BUFFER_SIZE) + { + buffer.rewind(); + RECYCLER.recycle(this, handle); + } } @Override http://git-wip-us.apache.org/repos/asf/cassandra/blob/578c85dc/src/java/org/apache/cassandra/utils/btree/BTree.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/utils/btree/BTree.java b/src/java/org/apache/cassandra/utils/btree/BTree.java index 5665869..33f4152 100644 --- a/src/java/org/apache/cassandra/utils/btree/BTree.java +++ b/src/java/org/apache/cassandra/utils/btree/BTree.java @@ -831,12 +831,17 @@ public class BTree public void recycle() { if (recycleHandle != null) + { + this.cleanup(); builderRecycler.recycle(this, recycleHandle); + } } - private void reuse(Comparator<? super V> comparator) + /** + * Cleans up the Builder instance before recycling it. + */ + private void cleanup() { - this.comparator = comparator; quickResolver = null; Arrays.fill(values, 0, count, null); count = 0; @@ -844,6 +849,11 @@ public class BTree auto = true; } + private void reuse(Comparator<? super V> comparator) + { + this.comparator = comparator; + } + public Builder<V> auto(boolean auto) { this.auto = auto;