You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Jason Brown (JIRA)" <ji...@apache.org> on 2017/09/07 20:02:00 UTC
[jira] [Commented] (CASSANDRA-13789) Reduce memory copies and
object creations when acting on ByteBufs
[ https://issues.apache.org/jira/browse/CASSANDRA-13789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16157547#comment-16157547 ]
Jason Brown commented on CASSANDRA-13789:
-----------------------------------------
Pushed a fix here:
||13789-fixes||
|[branch|https://github.com/jasobrown/cassandra/tree/13789-fixes]|
|[dtest|https://builds.apache.org/view/A-D/view/Cassandra/job/Cassandra-devbranch-dtest/291/]|
|[utests|https://circleci.com/gh/jasobrown/cassandra/tree/13789-fixes]|
The problem was in [~norman]'s patch, in both {{CBUtil#writeString}} and {{CBUtil#writeLongString}} he was bumping the writerIndex via {{ByteBuf#writerIndex(int)}}. The problem is that if the new writerIndex value exceeds the capacity of the buffer it throws an {{IndexOutOfBoundsException}}. Previously, we were calling {{ByteBuf#writeShort}} or {{ByteBuf#writeLong}}, which reallocates the buffer if the new writerIndex is larger than the current size.
For now, I've reverted to calling {{ByteBuf#writeShort}} (or {{ByteBuf#writeLong}}), to restore previous behavior (that passes!), and I've added a new {{CBUtilTest}}, as well.
As a further optimization, we can find out why the {{ByteBuf}} is being reallocated to begin with, but that's for another jira.
> Reduce memory copies and object creations when acting on ByteBufs
> ------------------------------------------------------------------
>
> Key: CASSANDRA-13789
> URL: https://issues.apache.org/jira/browse/CASSANDRA-13789
> Project: Cassandra
> Issue Type: Improvement
> Reporter: Norman Maurer
> Assignee: Norman Maurer
> Fix For: 4.0
>
> Attachments: 0001-CBUtil.sizeOfLongString-encodes-String-to-byte-to-ca.patch, 0001-Reduce-memory-copies-and-object-creations-when-actin.patch
>
>
> There are multiple "low-hanging-fruits" when it comes to reduce memory copies and object allocations when acting on ByteBufs.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org