anuraaga opened a new pull request #2579: Benchmark bytes / bytebuffer, protobuf vs zipkin
vs wire.
URL: https://github.com/apache/incubator-zipkin/pull/2579
For #2435
This is just a hacky set of code to compare performance of decoding `ByteBuffer` and `byte[]`.
I used the protobuf library mainly since it has native decoders for each type so is easiest
to compare. Naturally zipkin's `Buffer` could be updated to act on `ByteBuffer` directly to
avoid this, though I'm not sure it'd be faster. wire does especially poorly with `ByteBuffer`
it seems, since it just copies it into a `byte[]` but doesn't have netty's unsafe optimizations
like `ByteBufUtil.getBytes` would have.
As expected, wire is especially fast in time here, probably because it doesn't do hex decoding
- it's nowhere near an apple comparison and mainly for reference. Otherwise, `byte[]` seems
to be a bit faster, which isn't unexpected given the JVM is optimized for it, but the difference
is mainly in the noise throughout. This could possibly be considered enough reason to switch
to `ByteBuffer` though as given similar parsing time, `ByteBuffer` version is a bit better
since it generates no garbage and could potentially reduce GC.
```
Benchmark (num) Mode Cnt Score Error Units
ProtoCodecBenchmarks.bytebuffer_protobufDecoder 1 avgt 15 1.267 ± 0.014
us/op
ProtoCodecBenchmarks.bytebuffer_protobufDecoder 10 avgt 15 12.244 ± 0.165
us/op
ProtoCodecBenchmarks.bytebuffer_protobufDecoder 100 avgt 15 121.105 ± 1.388
us/op
ProtoCodecBenchmarks.bytebuffer_protobufDecoder 1000 avgt 15 1209.171 ± 18.580
us/op
ProtoCodecBenchmarks.bytebuffer_protobufDecoder 10000 avgt 15 12839.910 ± 771.469
us/op
ProtoCodecBenchmarks.bytebuffer_wireDecoder 1 avgt 15 0.214 ± 0.018
us/op
ProtoCodecBenchmarks.bytebuffer_wireDecoder 10 avgt 15 0.969 ± 0.064
us/op
ProtoCodecBenchmarks.bytebuffer_wireDecoder 100 avgt 15 8.317 ± 0.600
us/op
ProtoCodecBenchmarks.bytebuffer_wireDecoder 1000 avgt 15 90.706 ± 2.031
us/op
ProtoCodecBenchmarks.bytebuffer_wireDecoder 10000 avgt 15 1039.518 ± 65.438
us/op
ProtoCodecBenchmarks.bytebuffer_zipkinDecoder 1 avgt 15 1.389 ± 0.049
us/op
ProtoCodecBenchmarks.bytebuffer_zipkinDecoder 10 avgt 15 13.393 ± 0.802
us/op
ProtoCodecBenchmarks.bytebuffer_zipkinDecoder 100 avgt 15 111.140 ± 2.660
us/op
ProtoCodecBenchmarks.bytebuffer_zipkinDecoder 1000 avgt 15 1234.412 ± 106.794
us/op
ProtoCodecBenchmarks.bytebuffer_zipkinDecoder 10000 avgt 15 11658.781 ± 694.221
us/op
ProtoCodecBenchmarks.bytes_protobufDecoder 1 avgt 15 1.143 ± 0.031
us/op
ProtoCodecBenchmarks.bytes_protobufDecoder 10 avgt 15 11.733 ± 0.545
us/op
ProtoCodecBenchmarks.bytes_protobufDecoder 100 avgt 15 122.660 ± 7.020
us/op
ProtoCodecBenchmarks.bytes_protobufDecoder 1000 avgt 15 1287.893 ± 41.410
us/op
ProtoCodecBenchmarks.bytes_protobufDecoder 10000 avgt 15 11838.844 ± 184.314
us/op
ProtoCodecBenchmarks.bytes_wireDecoder 1 avgt 15 0.136 ± 0.005
us/op
ProtoCodecBenchmarks.bytes_wireDecoder 10 avgt 15 0.598 ± 0.024
us/op
ProtoCodecBenchmarks.bytes_wireDecoder 100 avgt 15 5.603 ± 0.113
us/op
ProtoCodecBenchmarks.bytes_wireDecoder 1000 avgt 15 67.543 ± 1.314
us/op
ProtoCodecBenchmarks.bytes_wireDecoder 10000 avgt 15 775.430 ± 72.922
us/op
ProtoCodecBenchmarks.bytes_zipkinDecoder 1 avgt 15 1.132 ± 0.061
us/op
ProtoCodecBenchmarks.bytes_zipkinDecoder 10 avgt 15 10.942 ± 0.225
us/op
ProtoCodecBenchmarks.bytes_zipkinDecoder 100 avgt 15 117.941 ± 8.454
us/op
ProtoCodecBenchmarks.bytes_zipkinDecoder 1000 avgt 15 1279.525 ± 73.367
us/op
ProtoCodecBenchmarks.bytes_zipkinDecoder 10000 avgt 15 12400.006 ± 469.528
us/op
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
|