-
Notifications
You must be signed in to change notification settings - Fork 115
use minimal protobufjs #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks! This increases the size of SDK: Before:
After:
And during
Do you think it's better than before with these changes? I think the problem of eval somewhere in protobufjs still exists? |
File size growth: Eval usage: |
Thanks @wrangelvid ! Please let me know if you find sth, will try to look closer too when exactly eval is used in protobufjs, now it's not very clear to me whether current implementation of centrifuge-js uses it or not in practice, or rollup complains just because eval is found in protobufjs source code. |
I made an interesting discovery. What do we care more about? The minified file size or the gzip size that actually goes over network? When we run
|
LOL, very nice :) I think gzipped is more important. Also ran benchmark and this version shows better encoding speed: 4.90 µs/op vs 6.19 µs/op in current implementation. Will allocate more time to look at code generation and hopefully good to go 🤞 |
Hello @wrangelvid So I looked at changes, and tested how it works with examples - everything seems good. While testing I found an issue with current bench suite - it tried to decode encoded commands, not replies. New bench results with applied fix on top of master and this PR: Before:
With this PR:
So it also improves decoding. Also looked at source code generated by esbuild, it still includes:
Not sure maybe it's just can't be tree-shaked, maybe required for something. I think I may try to go with solution in protobufjs/protobuf.js#2057 (comment) - override dependency to |
The issues surrounding @protobufjs/inquire make the eval story quite frustrating, but I’m glad someone else cut a release of the subpackage! |
Agree.. Strange situation without enough attention from maintainers. Released https://github.com/centrifugal/centrifuge-js/releases/tag/5.4.0 with this PR included, let's see how it goes. Many thanks for contributing! |
Per our discussion, this is a version using the minimal version of protobufjs, which avoids eval.
I tried to be minimially invasive in this PR. Open to feedback.