cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benedict (JIRA)" <>
Subject [jira] [Commented] (CASSANDRA-6697) Refactor Cell and CellName ByteBuffer accessors to avoid garbage allocation where possible
Date Thu, 13 Feb 2014 11:48:21 GMT


Benedict commented on CASSANDRA-6697:

There is another option still, that might meet all of the criteria: instead of providing the
scope, you provide something that to the accessor looks basically the same, but for which
the resultant function is not defined (from the POV of the accessor). Callers of the accessors
select the correct function: for comparisons we could grab a thread-local instance on which
we set the comparator we want to actually compare with, and then pass in to the accessors
a left() and right() function that is used to populate the comparator. The internal logic
will be dependent on the same concepts as the scope approach, but the correct scoping should
be enforced, assuming you don't use the function incorrectly.

The downside is it might have slightly increased overhead. For comparisons, for instance,
you'd probably need a special object with two child (left/right) objects which are passed
to the accessors to wire up either side of the comparison. It also isn't as flexible.

A further option still (still) is to have a special accessor for the function we want to perform.
Since most of the time we just want to avoid the cost we care about comparison, having a special
compareTo() method, and a special writeTo(BB) might be enough to deal with most of the situations
we'll encounter. It won't help us when comparing two off-heap instances, though, without a
further specialised accessor, without which we would probably not eliminate much of the O(
N ) garbage during merging/collation of results. Still, this may be the best of the options
other than the current tree.

> Refactor Cell and CellName ByteBuffer accessors to avoid garbage allocation where possible
> ------------------------------------------------------------------------------------------
>                 Key: CASSANDRA-6697
>                 URL:
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Benedict
>             Fix For: 2.1
> This is a prerequisite for CASSANDRA-6689.
> The basic idea is to, if unsafe is available, abuse it to modify preallocated ByteBuffers
so that when they are short lived they do not need to be instantiated. Initially this will
only be helpful for comparisons and lookups on the BBs, but with some modifications to the
read path we should be able to reduce the need in CASSANDRA-6689 to construct BBs to pass
to the native protocol (thrift may have to continue as is)

This message was sent by Atlassian JIRA

View raw message