grpc-web icon indicating copy to clipboard operation
grpc-web copied to clipboard

is it worth re-implementing this client with protobuf.js?

Open chadi-kazan opened this issue 5 years ago • 8 comments

instead of google-protobuf? I am seeing 1 in 10 requests suffering a considerable lag. Looking at protobuf.js, they seem to claim their implementation is more efficient than google-protobuf. the library however seems quite old so it's not clear if this still stands. is it worth re-implementing this client with protobuf.js?

chadi-kazan avatar Feb 18 '20 13:02 chadi-kazan

I think it'd make sense to make it an option - but I think this might be the wrong repo? I think these changes would have to be made in https://github.com/improbable-eng/ts-protoc-gen. At the moment it expects to be generated into the same folder as the js_out output. I imagine it should be possible to add a variable that means it could assume to be used together with protobuf.js. What do you think?

johanbrandhorst avatar Feb 18 '20 14:02 johanbrandhorst

I just wanted to test replacing the google-protobuf encoding and decoding with the protobufjs implementation. I managed to hack a POC. correct me if am wrong, but there would be no real difference in performance if we use the javascript objects generated by protobufjs instead of those generated by google-protobuf, right? the performance difference as, i understood, lies in the encodig /decoding process.

chadi-kazan avatar Feb 20 '20 15:02 chadi-kazan

I think that's right, but we must obviously remain compatible with both (for backwards compatibility) if we're adding this.

johanbrandhorst avatar Feb 20 '20 15:02 johanbrandhorst

I see. and agree. that said, would you have an idea where this lag could be coming from?

chadi-kazan avatar Feb 20 '20 16:02 chadi-kazan

Nope - the frontend isn't really my area of expertise. Maybe do some profiling?

johanbrandhorst avatar Feb 20 '20 16:02 johanbrandhorst

I want to have the ability of deserializeJson, but google-protobuf doesn't supply so I'm interested in the protobuf.js version working with grpc-web.

fatfatson avatar Oct 05 '20 13:10 fatfatson

image Currently the biggest part of our bundle is the google-protobuf library. protobuf.js is 73.2Kb, google-protobuf.js is 229.5Kb. It would be very useful if there was a way to use protobuf.js as an alternative.

bluskript avatar Jan 18 '21 19:01 bluskript

It would also make sense to do so because google-protobuf does not comply with unsafe-eval CSP, which makes it not possible to use out of the box in Web Extensions.

See: https://github.com/protocolbuffers/protobuf-javascript/issues/25

markin-io avatar Jan 12 '23 21:01 markin-io