elodina / go-avro

Apache Avro for Golang
http://elodina.github.io/go-avro/
Apache License 2.0
128 stars 55 forks source link

Datum reader improvements #66

Closed serejja closed 8 years ago

serejja commented 8 years ago

This PR improves performance of findField and mapEnum.

Benchmark results before changes (Core i5-3230M CPU @ 2.60GHz × 4):

BenchmarkSpecificDatumReader_complex-4    300000          4092 ns/op
BenchmarkSpecificDatumReader_hugeval-4    300000          4412 ns/op
BenchmarkEncodeVarint32-4               30000000            44.3 ns/op
BenchmarkEncodeVarint64-4               30000000            43.7 ns/op
BenchmarkSpecificDatumWriter-4            500000          3932 ns/op

After:

BenchmarkSpecificDatumReader_complex-4    500000          3375 ns/op         336 B/op         12 allocs/op
BenchmarkSpecificDatumReader_hugeval-4   2000000           662 ns/op          32 B/op          1 allocs/op
BenchmarkEncodeVarint32-4               30000000            43.7 ns/op
BenchmarkEncodeVarint64-4               30000000            43.6 ns/op
BenchmarkSpecificDatumWriter-4            500000          3715 ns/op

benchcmp results:

benchmark                                  old ns/op     new ns/op     delta       
BenchmarkSpecificDatumReader_complex-4     4092          3375          -17.52%     
BenchmarkSpecificDatumReader_hugeval-4     4412          662           -85.00%     
BenchmarkEncodeVarint32-4                  44.3          43.7          -1.35%      
BenchmarkEncodeVarint64-4                  43.7          43.6          -0.23%      
BenchmarkSpecificDatumWriter-4             3932          3715          -5.52%