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

Benedict Elliott Smith edited comment on CASSANDRA-15215 at 10/31/21, 5:57 PM:
-------------------------------------------------------------------------------

Hi [~Gerrrr],

Thanks for picking this up, but what you've proposed in the patch isn't quite 
what I had in mind. The premise is to introduce a new method to 
{{DataOutputPlus}} that is able to write up to 8 bytes from a long, so it would 
be something like {{putBytes(long register, int bytes)}} where {{bytes<=8}}. If 
there are more than 8 bytes left in the underlying storage then 
{{putLong(offset, register)}} is invoked on any underlying {{ByteBuffer}}, and 
the offset counter is incremented only by {{bytes}}.

This same approach can of course be performed directly to a {{ByteBuffer}}, and 
symmetrically for {{readBytes(bytes)}} with {{DataInputPlus}}.

This way the vint can be assembled and inserted using simple register 
instructions while there is >= 8 bytes in the underlying storage buffer, i.e. 
the majority of instances. Otherwise we could fall back to this suggested 
approach or any other.


was (Author: benedict):
Hi [~Gerrrr],

Thanks for picking this up, but what you've proposed in the patch isn't quite 
what I had in mind. The premise is to introduce a new method to 
{{DataOutputPlus}} that is able to write up to 8 bytes from a long, so it would 
be something like {{putBytes(long register, int bytes)}} where {{bytes<=8}}. If 
there are more than 8 bytes left in the underlying storage then 
{{putLong(offset, register)}} is invoked, but the byte counter is incremented 
only by {{bytes}}.

This same approach can of course be performed directly to a {{ByteBuffer}} 
also, and symmetrically for {{readBytes(bytes)}} with {{DataInputPlus}}.

This way the vint can be assembled and inserted using simple register 
instructions while there is >= 8 bytes in the underlying storage buffer, i.e. 
the majority of instances. Otherwise we could fall back to this suggested 
approach or any other.

> VIntCoding should read and write more efficiently
> -------------------------------------------------
>
>                 Key: CASSANDRA-15215
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15215
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Local/Compaction, Local/SSTable
>            Reporter: Benedict Elliott Smith
>            Assignee: Aleksandr Sorokoumov
>            Priority: Normal
>             Fix For: 3.0.x, 3.11.x, 4.x
>
>
> Most vints occupy significantly fewer than 8 bytes, and most buffers have >= 
> 8 bytes spare, in which case we can construct the relevant bytes in a 
> register and memcpy them to the correct position.  Since we read and write a 
> lot of vints, this waste is probably measurable, particularly during 
> compaction and flush, and can probably be considered a performance bug.



--
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