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

Aleksandr Sorokoumov commented on CASSANDRA-15215:
--------------------------------------------------

Short status update: I just pushed changes to the benchmarks as suggested by 
Branimir and Benedict. The changes are:
 * All tests have monomorphic, bimorphic, and megamorphic versions.
 * Added a test that writes random longs to the ByteBuffer.
 * Added a test for calculating VInt size and applied Branimir's formula.

Results:
h4. Baseline
{noformat}
Benchmark                                    (allocation)  Mode  Cnt   Score   
Error  Units
VIntCodingBench.testComputeUnsignedVIntSize   monomorphic  avgt   15  17.069 ± 
1.087  ns/op
VIntCodingBench.testComputeUnsignedVIntSize     bimorphic  avgt   15  17.323 ± 
0.656  ns/op
VIntCodingBench.testComputeUnsignedVIntSize   megamorphic  avgt   15  16.791 ± 
0.473  ns/op
VIntCodingBench.testWrite1Byte                monomorphic  avgt   15   9.047 ± 
0.254  ns/op
VIntCodingBench.testWrite1Byte                  bimorphic  avgt   15  16.935 ± 
0.207  ns/op
VIntCodingBench.testWrite1Byte                megamorphic  avgt   15  17.835 ± 
0.090  ns/op
VIntCodingBench.testWrite2Bytes               monomorphic  avgt   15  18.612 ± 
0.194  ns/op
VIntCodingBench.testWrite2Bytes                 bimorphic  avgt   15  25.033 ± 
0.239  ns/op
VIntCodingBench.testWrite2Bytes               megamorphic  avgt   15  28.352 ± 
0.115  ns/op
VIntCodingBench.testWrite3Bytes               monomorphic  avgt   15  21.333 ± 
0.197  ns/op
VIntCodingBench.testWrite3Bytes                 bimorphic  avgt   15  26.173 ± 
0.170  ns/op
VIntCodingBench.testWrite3Bytes               megamorphic  avgt   15  29.983 ± 
0.208  ns/op
VIntCodingBench.testWrite4Bytes               monomorphic  avgt   15  21.229 ± 
0.245  ns/op
VIntCodingBench.testWrite4Bytes                 bimorphic  avgt   15  28.966 ± 
0.606  ns/op
VIntCodingBench.testWrite4Bytes               megamorphic  avgt   15  33.219 ± 
1.276  ns/op
VIntCodingBench.testWrite5Bytes               monomorphic  avgt   15  22.886 ± 
0.602  ns/op
VIntCodingBench.testWrite5Bytes                 bimorphic  avgt   15  29.209 ± 
1.077  ns/op
VIntCodingBench.testWrite5Bytes               megamorphic  avgt   15  32.731 ± 
0.944  ns/op
VIntCodingBench.testWrite6Bytes               monomorphic  avgt   15  22.579 ± 
0.794  ns/op
VIntCodingBench.testWrite6Bytes                 bimorphic  avgt   15  29.067 ± 
0.678  ns/op
VIntCodingBench.testWrite6Bytes               megamorphic  avgt   15  35.419 ± 
1.496  ns/op
VIntCodingBench.testWrite7Bytes               monomorphic  avgt   15  22.823 ± 
0.527  ns/op
VIntCodingBench.testWrite7Bytes                 bimorphic  avgt   15  29.521 ± 
1.216  ns/op
VIntCodingBench.testWrite7Bytes               megamorphic  avgt   15  34.295 ± 
2.327  ns/op
VIntCodingBench.testWrite8Bytes               monomorphic  avgt   15  22.032 ± 
0.918  ns/op
VIntCodingBench.testWrite8Bytes                 bimorphic  avgt   15  30.388 ± 
1.015  ns/op
VIntCodingBench.testWrite8Bytes               megamorphic  avgt   15  33.632 ± 
1.200  ns/op
VIntCodingBench.testWrite9Bytes               monomorphic  avgt   15  22.616 ± 
1.309  ns/op
VIntCodingBench.testWrite9Bytes                 bimorphic  avgt   15  29.291 ± 
1.096  ns/op
VIntCodingBench.testWrite9Bytes               megamorphic  avgt   15  32.597 ± 
0.807  ns/op
VIntCodingBench.testWriteRandomLong           monomorphic  avgt   15  35.010 ± 
1.145  ns/op
VIntCodingBench.testWriteRandomLong             bimorphic  avgt   15  43.090 ± 
0.615  ns/op
VIntCodingBench.testWriteRandomLong           megamorphic  avgt   15  43.196 ± 
1.742  ns/op
{noformat}
h4. Patch
{noformat}
VIntCodingBench.testComputeUnsignedVIntSize   monomorphic  avgt   15  16.339 ± 
0.418  ns/op
VIntCodingBench.testComputeUnsignedVIntSize     bimorphic  avgt   15  16.340 ± 
0.417  ns/op
VIntCodingBench.testComputeUnsignedVIntSize   megamorphic  avgt   15  16.435 ± 
0.408  ns/op
VIntCodingBench.testWrite1Byte                monomorphic  avgt   15   9.362 ± 
0.208  ns/op
VIntCodingBench.testWrite1Byte                  bimorphic  avgt   15  18.164 ± 
0.839  ns/op
VIntCodingBench.testWrite1Byte                megamorphic  avgt   15  19.800 ± 
0.942  ns/op
VIntCodingBench.testWrite2Bytes               monomorphic  avgt   15  10.094 ± 
0.444  ns/op
VIntCodingBench.testWrite2Bytes                 bimorphic  avgt   15  18.310 ± 
0.813  ns/op
VIntCodingBench.testWrite2Bytes               megamorphic  avgt   15  19.685 ± 
0.692  ns/op
VIntCodingBench.testWrite3Bytes               monomorphic  avgt   15  11.541 ± 
0.433  ns/op
VIntCodingBench.testWrite3Bytes                 bimorphic  avgt   15  19.087 ± 
0.720  ns/op
VIntCodingBench.testWrite3Bytes               megamorphic  avgt   15  20.518 ± 
1.035  ns/op
VIntCodingBench.testWrite4Bytes               monomorphic  avgt   15  10.677 ± 
0.417  ns/op
VIntCodingBench.testWrite4Bytes                 bimorphic  avgt   15  18.815 ± 
0.921  ns/op
VIntCodingBench.testWrite4Bytes               megamorphic  avgt   15  21.106 ± 
0.731  ns/op
VIntCodingBench.testWrite5Bytes               monomorphic  avgt   15  11.564 ± 
0.549  ns/op
VIntCodingBench.testWrite5Bytes                 bimorphic  avgt   15  18.961 ± 
0.783  ns/op
VIntCodingBench.testWrite5Bytes               megamorphic  avgt   15  20.939 ± 
0.541  ns/op
VIntCodingBench.testWrite6Bytes               monomorphic  avgt   15  13.463 ± 
0.441  ns/op
VIntCodingBench.testWrite6Bytes                 bimorphic  avgt   15  20.188 ± 
0.792  ns/op
VIntCodingBench.testWrite6Bytes               megamorphic  avgt   15  23.087 ± 
1.044  ns/op
VIntCodingBench.testWrite7Bytes               monomorphic  avgt   15  12.655 ± 
0.347  ns/op
VIntCodingBench.testWrite7Bytes                 bimorphic  avgt   15  21.307 ± 
0.892  ns/op
VIntCodingBench.testWrite7Bytes               megamorphic  avgt   15  23.209 ± 
0.526  ns/op
VIntCodingBench.testWrite8Bytes               monomorphic  avgt   15  11.712 ± 
0.404  ns/op
VIntCodingBench.testWrite8Bytes                 bimorphic  avgt   15  19.179 ± 
0.730  ns/op
VIntCodingBench.testWrite8Bytes               megamorphic  avgt   15  20.692 ± 
0.627  ns/op
VIntCodingBench.testWrite9Bytes               monomorphic  avgt   15  12.029 ± 
0.387  ns/op
VIntCodingBench.testWrite9Bytes                 bimorphic  avgt   15  19.826 ± 
0.971  ns/op
VIntCodingBench.testWrite9Bytes               megamorphic  avgt   15  21.953 ± 
0.450  ns/op
VIntCodingBench.testWriteRandomLong           monomorphic  avgt   15  24.668 ± 
0.523  ns/op
VIntCodingBench.testWriteRandomLong             bimorphic  avgt   15  31.157 ± 
0.832  ns/op
VIntCodingBench.testWriteRandomLong           megamorphic  avgt   15  32.698 ± 
1.376  ns/op
{noformat}
Next week I plan to start working on {{{}DataOutputPlus#writeBytes(long 
register, int bytes){}}}.

> 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.20.1#820001)

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

Reply via email to