[
https://issues.apache.org/jira/browse/AVRO-4067?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17885654#comment-17885654
]
David Mollitor commented on AVRO-4067:
--------------------------------------
There already exists a JMH test in the 'perf' package to test this:
{{org.apache.avro.perf.test.basic.BytesTest.decode}}
Here are my results, but as always YMMV.
{code}
Benchmark Mode Cnt Score Error Units
BytesTest.decode thrpt 10 17105725.454 ± 193288.518 ops/s # master
BytesTest.decode thrpt 10 17478500.118 ± 295699.206 ops/s # AVRO-4067
{code}
> Optimize First Byte of Long Decode
> ----------------------------------
>
> Key: AVRO-4067
> URL: https://issues.apache.org/jira/browse/AVRO-4067
> Project: Apache Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.12.0
> Reporter: David Mollitor
> Assignee: David Mollitor
> Priority: Minor
> Fix For: 1.13.0
>
>
> Long values are used for many different areas of the spec, for example:
>
> bq. a string is encoded as a long followed by that many bytes of UTF-8
> encoded character data.
> Because of this, long values actually tend to be pretty small on average, and
> so can often fit within the first byte of the variable-length array.
> Therefore, the first byte should be prioritized.
> For the first byte, if the high-order bit is set, then not only does it mean
> there are more bytes to follow, but that the signed value of the byte will be
> negative. Therefore, the inverse is that for a positive number (>=0), then
> there are not more bytes to follow.
> Check the first byte, and if it is positive, exit early, if it is zero,
> return zero.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)