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

Robert Stupp commented on CASSANDRA-15393:
------------------------------------------

Thanks for tackling this! Heap pressure induced by {{ByteBuffer}} is definitely 
a pita. I'm not sure though whether this patch is suitable to be included in 
4.0 this late (beta stage) as it looks quite intrusive and is pretty big.
 Haven't thoroughly reviewed it, but here are a few notes:
 * The new *Accessor classes have constants for boolean (true/false) 
representations, which are modifiable. IIRC there's been an issue in the past 
when that (or a similar) constant was accidentally changed.
 * The split of {{ByteBuffer}} into a pair of {{accessor + container}} is error 
prone - e.g. accidentally passing a {{byte[]}} with the {{ByteBufferAccessor}} 
or vice versa leads to "interesting" results.

The underlying issue IMO is not {{ByteBuffer}} itself but the vast amount of 
those intermediate and often tiny BB instances. But introducing an API that's 
error prone is dangerous.

It feels both more efficient and much safer to have an API & implementation 
that actually _prevents_ (the vast majority of) these new objects. I.e. instead 
of creating a new {{ByteBuffer}} (or "just" a new {{byte[]}} as in the PR) to 
write some value (e.g. an {{int}}) to a target buffer, write that value 
_directly_ into the target buffer. _How_ that's implemented is a different 
topic, but I'd prefer to consider all the new developments in Java and make it 
safe & transparent to use.

> 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: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to