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

introduce a NOP template for cc #533

Merged
merged 3 commits into from Jan 28, 2022
Merged

Conversation

Reflejo
Copy link
Contributor

@Reflejo Reflejo commented Nov 4, 2021

This is a stopgap before we can land #531 and its corresponding rules_go change.

What we really trying to achieve in https://github.com/envoyproxy/envoy-mobile is to be able to compile out the protos validate logic which takes a ton of space. This change helps achieving that without any code modification on envoy.

@mattklein123
Copy link
Contributor

cc @akonradi @rodaine any thoughts on this? The general background here is that the validate code takes up a large mount of binary space in Envoy Mobile and we would like to be able to compile it out. There are various ways we can do this, but this seems like a pretty easy quick fix (hack) that we could use until we get the full template override solution? WDYT?

@akonradi
Copy link
Contributor

akonradi commented Nov 4, 2021

My first inclination is to say "why not do this with templates in consuming code and let the linker prune?" but I assume that's approximately the "full template override solution". I don't love the idea of generating incorrect code but as a stop-gap this seems okay since it's opt-in.

@rodaine
Copy link
Member

rodaine commented Nov 4, 2021

+1 to @akonradi's comments. Either this, or allow a user to specify a sort of "stub-mode" for all languages that does this behavior across the board. Either's fine from my perspective, with something like #531 being the ideal longer-term path forward.

@Reflejo
Copy link
Contributor Author

Reflejo commented Nov 4, 2021

I think #531 is the right direction. But we need a stopgap given how hard it is to updates rules_go in envoy. So we were hopping to get this in asap.

What do you all think about getting this stopgap in for the time being?

@Reflejo Reflejo marked this pull request as ready for review November 4, 2021 19:31
@mattklein123
Copy link
Contributor

What do you all think about getting this stopgap in for the time being?

I'm +1 for going with this for now as it addresses an immediate need and is pretty simple. Can we add some basic tests and docs about this in the README or wherever is applicable?

@rodaine
Copy link
Member

rodaine commented Nov 5, 2021

I'm +1 for going with this for now as it addresses an immediate need and is pretty simple. Can we add some basic tests and docs about this in the README or wherever is applicable?

@Reflejo if you can address these, happy to approve :D

@Reflejo
Copy link
Contributor Author

Reflejo commented Nov 18, 2021

@rodaine Ok picking this up again. Where would you recommend to add tests for this? Unsurprisingly there is no precedence of a test that would need a different BAZEL invocation (We'd need to pass template-flavor=nop for that particular test).

@Reflejo
Copy link
Contributor Author

Reflejo commented Nov 30, 2021

@rodaine thoughts? I haven't found an easy way on the current test setup to include a test with a different bazel invocation. I could wire up a bunch of bazel primitives only for testing, but is it worth it for a temporary solution?

@mattklein123 mattklein123 self-assigned this Nov 30, 2021
@rodaine
Copy link
Member

rodaine commented Dec 1, 2021

It's been a long time since I've messed with Bazel. Can we create a new, specific test target that just handles the nop case? The test case for those will just be 1) that it compiles, and 2) that it never returns a validation error. I don't think this'll fit into the existing tests, and probably will be more work than it's worth to wedge it in.

@mattklein123
Copy link
Contributor

@Reflejo what's the status of this? Do you want to pick this up again and get this in?

@Reflejo Reflejo force-pushed the fz/cc_nop branch 2 times, most recently from 7304c23 to 94534e3 Compare January 28, 2022 21:40
Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
Copy link
Contributor

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that testing this change requires so much work, I think it's reasonable to merge this. It will be obvious to any consumers if this new feature is broken.

@mattklein123 mattklein123 merged commit 79071f0 into bufbuild:main Jan 28, 2022
Reflejo added a commit to Reflejo/envoy-mobile that referenced this pull request Feb 10, 2022
This change updates pgv to a version that supports a "cc nop" language. With
that we can make the validation functions a NOP that hopefuly gets inlined.

This is the PGV change for reference: bufbuild/protoc-gen-validate#533

Size delta: -3.7 Mi
Reflejo added a commit to Reflejo/envoy-mobile that referenced this pull request Feb 10, 2022
This change updates pgv to a version that supports a "cc nop" language. With
that we can make the validation functions a NOP that hopefuly gets inlined.

This is the PGV change for reference: bufbuild/protoc-gen-validate#533

Size delta: -3.7 Mi

Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
Reflejo added a commit to Reflejo/envoy-mobile that referenced this pull request Feb 10, 2022
This change updates pgv to a version that supports a "cc nop" language. With
that we can make the validation functions a NOP that hopefuly gets inlined.

This is the PGV change for reference: bufbuild/protoc-gen-validate#533

Size delta: -3.7 Mi

Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
Reflejo added a commit to Reflejo/envoy-mobile that referenced this pull request Feb 18, 2022
This change updates pgv to a version that supports a "cc nop" language. With
that we can make the validation functions a NOP that hopefuly gets inlined.

This is the PGV change for reference: bufbuild/protoc-gen-validate#533

Size delta: -3.7 Mi

Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
jpsim pushed a commit to envoyproxy/envoy-mobile that referenced this pull request Feb 18, 2022
* size: compile releases optimizing for code size

Size delta: -0.66 Mi

* size: set default visibility to hidden

The .dynstr section of the binary as well as the symbol table is pretty big
for a shared library with almost no (intended to be) exported symbols. This
change makes all symbols hidden by default. We should test and add to visible
if some are missing.

Size delta: -5.66Mi

* size: override pgv validations with NOP functions

This change updates pgv to a version that supports a "cc nop" language. With
that we can make the validation functions a NOP that hopefuly gets inlined.

This is the PGV change for reference: bufbuild/protoc-gen-validate#533

Size delta: -3.7 Mi

Signed-off-by: Martin Conte Mac Donell <reflejo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants