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
Use slimmer protobuf definitions on k8s structures #11326
Conversation
test-me-please |
a05d731
to
a6d0b8e
Compare
test-me-please |
a6d0b8e
to
bd2804d
Compare
test-me-please |
bd2804d
to
e642d21
Compare
test-me-please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive memory improvements!
Didn't review in depth, but mainly mainly checked the code generation parts and usage of the new types.
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Code generated by client-gen. DO NOT EDIT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to the contents of this PR, just something that puzzled me during review:
I was wondering why GitHub didn't recognize this file as being auto-generate despite this line being present while other files with the same comment are correctly recongnized. Turns out that github-linguist
only checks the first 10 lines of a file for the Code generated by
line:
However, https://golang.org/s/generatedcode states that the comment may appear anywhere in the file. I wonder whether it'd be possible to improve github-linguist
in that regard /cc @pchaigno
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, Linguist performs a best-effort detection of generated files in that regard. We impose a limit because we want to avoid searching potentially huge files. Nevertheless, in the present case, I think the limit could be bumped to match the longest license text that could be included here (probably BSD 4-clause, so about 40 lines).
If you want to send a quick fix for that, I can make sure it gets included in the next release (usually once a month).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for elaborating @pchaigno. I agree that it wouldn't make sense to search the whole file. Will send a quick fix bumping the limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sent PR github-linguist/linguist#4857
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also switch to SPDX to minimize boilerplate and not have to search so much :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also switch to SPDX to minimize boilerplate and not have to search so much :-)
Please do, so we have it for our code-base everywhere, not just C code. :-)
e642d21
to
7c473aa
Compare
test-me-please |
1 similar comment
test-me-please |
5b4ed49
to
25eae2c
Compare
Signed-off-by: André Martins <andre@cilium.io>
With these slimmer structures Cilium will only unmarshal the fields that it uses as opposed to unmarshal all fields and later on ignore the unused fields. For now, only Pod will be added as a PoC, later on all other k8s structures will have a similar change. Signed-off-by: André Martins <andre@cilium.io>
Signed-off-by: André Martins <andre@cilium.io>
With this slimmer Pod structure, Cilium won't need to convert a Pod into another structure that Cilium understands. This conversion will automatically happen when doing the unmarshal of k8s event. Thus, providing better memory management as well as CPU consumption since Cilium will only unmarshal the fields that actually need. Signed-off-by: André Martins <andre@cilium.io>
test-me-please |
25eae2c
to
16ce14e
Compare
In some cases (e.g. the Cilium project) the `Code generated by` comment appears after a license header. This header might be longer than 10 lines which generated_go currently searches for this comment. Bump the limit to 40 lines (roughly corresponding to the length of the BSD 4-clause header + some slack) to detect these cases. Suggested by Paul Chaignon in cilium/cilium#11326 (comment)
With this slimmer Pod structure, Cilium won't need to convert a Pod into
another structure that Cilium understands. This conversion will
automatically happen when doing the unmarshal of k8s event. Thus,
providing better memory management as well as CPU consumption since
Cilium will only unmarshal the fields that actually need.
Note for reviewers:
pkg/k8s/types/slim/README.md
Benchmark for 50k pods (memory allocated):
base
changes