Skip to content

Javascript code is extraordinarily slow #39

Open
@Timmmm

Description

@Timmmm

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 Inners and 700k Items 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions