Open wilhelmberg opened 8 years ago
Working on refactoring to full lazy decoding (branch 'breakout-full-decoding') and looking at profiling now:
Ran through the 210 streets+terrain tiles of mvt-bench-fixtures 100 times (equals decoding of 21,000 tiles
).
Results of bench.exe
on my MacBook (compiled with Release
, with Debug
it takes roughly twice the time):
runs:100
tiles per run:210
min [ms]:240
max [ms]:304
avg [ms]:262,17
StdDev:12,52
overall [ms]:26217
This means decoding all 210 tiles of the repo takes on average 0.262 seconds.
@springmeyer wrt optimizations we talked about, there doesn't seem to be a lot of potential for improvement:
Varint()
stands out with 23% but it also gets called 365.916.233 times.
Might be worth to implement differently, Assembler maybe 😏 - but that would probably not be cross platform.
Enum.IsDefined
which gets called often and is known to be slow, eg with a Dictionary/Hastable
. First test here.Varint()
, e.g. https://github.com/mapbox/protozero/blob/master/include/protozero/varint.hppbyte[]
around but only offsets and keep just one array in VectorTileReader
🎉 🎆 25% faster!
Some more profiling revealed why Variant()
showed up high:
It was the Pos
ition property of PbfReader
that gets called a lot.
Changed the property to a private field and speed increased by 2 seconds.
Did some other minor changes and decoding of 21,000 tiles is now down to 19.6 seconds from 26.2 before, meaning +1,000 tiles/sec:
runs : 100
tiles per run : 210
min [ms] : 186
max [ms] : 250
avg [ms] : 196,93
StdDev : 14,12
overall [ms] : 19693
tiles/sec : 1066,3
I suggest we leave as is for now, until we get some feedback that we need to squeeze out more performance. Will clean up and PR next week.
Didn't find a way to improve Varint()
:
inline
options are not available with .Net Framework 3.5 (we are stuck to that because of Unity
)unsafe
code blocks should work with native Unity
players (some hacks necessary tough: like creating a custom file that unblocks hidden settings) but are not supported by the WebPlayer.
Initial micro optimization are done: https://github.com/mapbox/vector-tile-cs/issues/15#issuecomment-258843441 https://github.com/mapbox/vector-tile-cs/pull/16
Revisit after https://github.com/mapbox/vector-tile-cs/issues/12 https://github.com/mapbox/vector-tile-cs/issues/7 https://github.com/mapbox/vector-tile-cs/issues/3