You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Tatu Saloranta (Jira)" <ji...@apache.org> on 2024/12/09 16:49:00 UTC
[jira] [Comment Edited] (CASSJAVA-60) Improve encoding performance of `CqlVector` by avoiding allocation of large number of temp `ByteBuffer`s
[ https://issues.apache.org/jira/browse/CASSJAVA-60?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17904216#comment-17904216 ]
Tatu Saloranta edited comment on CASSJAVA-60 at 12/9/24 4:48 PM:
-----------------------------------------------------------------
I checked out `4.x` branch of "https://github.com/apache/cassandra-java-driver.git".
Yes, the overhead is not about memory usage itself (it being transient) as much as cost of allocating and garbage collecting large number of individual small buffers unnecessarily (that is, excessive garbage generation).
And as I mentioned, there is already an alternate implementation that avoids that overhead and seems fairly straight-forward.
was (Author: tatu-at-datastax):
I checked out `4.x` branch of "https://github.com/apache/cassandra-java-driver.git".
Yes, the overhead is not about memory usage itself (it being transient) as much as cost of allocating and garbage collecting large number of individual small buffers unnecessarily. And as I mentioned, there is already an alternate implementation that avoids that overhead.
> 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: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org