Skip to content
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

protos: compile out unnecessary protos #178

Open
junr03 opened this issue Jun 25, 2019 · 8 comments
Open

protos: compile out unnecessary protos #178

junr03 opened this issue Jun 25, 2019 · 8 comments

Comments

@junr03
Copy link
Member

junr03 commented Jun 25, 2019

I noticed from object file analysis that compiled protos make up the biggest percentage of binary size:

  27.7%  2.32Mi  27.8%  2.36Mi compiled protos

More importantly, there are a lot of protos that are not needed in Envoy Mobile:

       2.4%  57.0Ki   2.4%  58.1Ki bazel-out/aarch64-opt/bin/external/envoy_api/envoy/admin/v2alpha/config_dump.pb.cc

However, upstream Envoy compiles all of these in, mostly because they are all needed in the server's bootstrap code. Given the size, it is worth it to investigate ways to compile out unnecessary protos. Or better yet, link in protos on-demand.

Size Win

This entirely depends on what protos we end up needing to link in, but the ceiling is ~2mb.

@stale
Copy link

stale bot commented Jul 26, 2019

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 26, 2019
@stale stale bot removed the stale label Jul 26, 2019
@junr03 junr03 added this to the v0.4 "Contorno" milestone Mar 19, 2020
@htuch
Copy link
Member

htuch commented Dec 3, 2020

@junr03 do you have any scripts or tooling for this kind of analysis that we could add to Envoy CI?

I'm interested in driving some automation around Envoy's dependencies, and we've added binary size to the policy in https://docs.google.com/document/d/1HbREo7pv7rgeIIjQn6mNpySzQE5rx2Yv9dXm5NqR2N8/edit#heading=h.xnpvc6pk0h0v.

It would be helpful to be able to quickly spot the binary size contribution from different libraries, and I'm guessing you might have already done some of this work.

@htuch
Copy link
Member

htuch commented Dec 3, 2020

Answering my own question, I think https://envoy-mobile.github.io/docs/envoy-mobile/latest/development/performance/binary_size.html captures this and we want to use Bloaty..

@junr03
Copy link
Member Author

junr03 commented Dec 4, 2020

@htuch yep, that's the process I follow. Using different bloaty configs with different path regexes affords you a lot of ways to dice the binary.

Awesome! Glad to see size making it in there. Lmk if I can be of help.

@alyssawilk
Copy link
Contributor

Also proto folks call out --copt='-DPROTOBUF_EXPERIMENTAL_USE_TAIL_CALL_TABLE_PARSER=1 as a new flag for improving size of files we could look into using

@alyssawilk
Copy link
Contributor

also proto lite if we can avoid reflection for mobile

@fowles
Copy link

fowles commented Mar 9, 2022

A high cost option in this space is to migrate to something based on https://github.com/protocolbuffers/upb

Protobuffer team is working on various aspects of this as part of long term strategies. It is important to note, however, that upb is an explicitly unstable api. It is intended to be an internal toolkit for building protobuf implementations.

@fowles
Copy link

fowles commented Mar 9, 2022

gRPC already does some of this https://github.com/grpc/grpc/tree/master/third_party/upb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants