Description
Version: 3.9.1
Language: Javascript
I have a message like this:
message Outer {
repeated Inner inner = 1;
}
message Inner {
repeated Item items = 1;
}
message Item {
uint32 a = 1;
uint32 b = 2;
uint32 c = 3;
uint32 d = 4;
uint32 e = 5;
}
It contains approximately 1000 Inner
s and 700k Item
s in total and comes out at about 10MB. Using the default Javascript implementation of protobufs it takes 10 seconds to decode. I switched to using Mapbox pbf, and that only takes 170 milliseconds.
I looked at PBF's code and they don't seem to be doing anything special. decodeVarint
looks like it has had some work to make Javascript engines happy with varints normally being less than 2^32, but... come on! That's 2 orders of magnitude! How is this implementation so slow?
Another issue is that this code generates objects with getters and setters, rather than just creating a plain object. Why? It just means I have to do even more tedious work when my message has been decoded to turn it into a form that I can easily use!