[ 
https://issues.apache.org/jira/browse/CASSANDRA-15393?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17173037#comment-17173037
 ] 

Benedict Elliott Smith commented on CASSANDRA-15393:
----------------------------------------------------

{quote}But introducing an API that's error prone is dangerous. But introducing 
an API that's error prone is dangerous.
{quote}
This particular issue can be somewhat resolved by using generic parameters for 
methods that accept the object and accessor, including the constructor of any 
object holding them, e.g.
{code:java}
public interface Accessor<Data> {}

public class SomethingWithData
{
    final Object data;
    final Accessor accessor;
    public <D> SomethingWithData(D data, Accessor<? super D> accessor) { 
this.data = data; this.accessor = accessor; }
} {code}
This avoids polluting the codebase with type parameters, but ensures the first 
supplier of the Object+Accessor is safe, and later supplies are safe if they 
only propagate pairs produced in this way.

We could also probably generify the objects themselves, I don't think it would 
be too painful - but this at least is an easy and less invasive improvement.

 
{quote}The underlying issue IMO is not {{ByteBuffer}} itself but the vast 
amount of those intermediate and often tiny BB instances.
{quote}
I don't have a strong opinion on the overall structural impact of this change; 
I haven't thought through the various options.  However I don't think we 
produce all that many intermediate {{ByteBuffer}} specifically, and though we 
do produce a lot of intermediate objects in many cases, there are workloads 
where this isn't the issue, and object creation is still a problem.

When it comes to compaction, my preferred approach would be to avoid 
materialising on heap at all - but the change here helps both compaction and 
reads/writes, so it doesn't have to be either/or, and we should definitely be 
trying to reduce our heap footprint in general.

> Add byte array backed cells
> ---------------------------
>
>                 Key: CASSANDRA-15393
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15393
>             Project: Cassandra
>          Issue Type: Sub-task
>          Components: Local/Compaction
>            Reporter: Blake Eggleston
>            Assignee: Blake Eggleston
>            Priority: Normal
>             Fix For: 4.0-beta
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> We currently materialize all values as on heap byte buffers. Byte buffers 
> have a fairly high overhead given how frequently they’re used, and on the 
> compaction and local read path we don’t do anything that needs them. Use of 
> byte buffer methods only happens on the coordinator. Using cells that are 
> backed by byte arrays instead in these situations reduces compaction and read 
> garbage up to 22% in many cases.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to