JuliaIO / ProtoBuf.jl

Julia protobuf implementation
Other
205 stars 55 forks source link

Specialize on type for large performance gains #184

Closed blegat closed 3 years ago

blegat commented 3 years ago

When reading andora.osm.pbf with OpenStreetMapX, the timing is: Before this PR:

julia> @time OpenStreetMapX.parsePBF("/home/blegat/Downloads/andorra-latest.osm.pbf");
  0.819850 seconds (1.58 M allocations: 183.134 MiB, 17.31% gc time)

After ProtoBuf PR:

julia> @time OpenStreetMapX.parsePBF("/home/blegat/Downloads/andorra-latest.osm.pbf");
  0.358973 seconds (1.14 M allocations: 176.507 MiB, 16.71% gc time)

So we get more than 2x speedup. The reason is that Julia is not specializing on jtyp hence I think the method lookup reader(iob, jtyp) is done at runtime instead of compilation time.