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

Jane He commented on CASSJAVA-60:
---------------------------------

Hi Tatu! Thank you for reporting this issue. I wonder which version of the Java 
driver you are looking at?


I took a look at the current master branch: 
[here|https://github.com/apache/cassandra-java-driver/blob/a322ca265654605123f4d7b889ad736c114f0c7e/core/src/main/java/com/datastax/oss/driver/internal/core/type/codec/VectorCodec.java#L66-L107].
 It seems to me that it first holds all the individual element's `ByteBuffer` 
in `ByteBuffer[] valueBuffs`, and then paste them one by one to `ByteBuffer 
rv`. So, it seems to me that it approximately uses 2 * the memory size of the 
return value `rv`. Is this what you refer to?

> Improve encoding performance of `CqlVector` by avoiding allocation of large 
> number of temp `ByteBuffer`s
> --------------------------------------------------------------------------------------------------------
>
>                 Key: CASSJAVA-60
>                 URL: https://issues.apache.org/jira/browse/CASSJAVA-60
>             Project: Apache Cassandra Java driver
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Tatu Saloranta
>            Priority: Normal
>
> When profiling service that uses Cassandra Java Driver, inserting rows with 
> Vector columns, I noticed that a significant source of generated garbage (and 
> cpu usage) was due to encoding of `CqlVector` (which is essentially thin 
> wrapper around `List<Float>`).
> A major reason is that value is encoded using delegation so that every 
> individual vector element is encoded separately into throw-away `ByteBuffer` 
> and only appended along with others in the end to get to actual full value.
> It should be possible to instead directly encode element values into fully 
> allocated target buffer (as element count & per-element size are known). And 
> possibly even just remove use of delegation if and when it is known that 
> elements are always `Float`s.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to