-
Notifications
You must be signed in to change notification settings - Fork 47
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
[CORE] Performance improvements #132
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edznux-dd
reviewed
Oct 19, 2023
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.
Nice! Huge improvements!
Looks good to me, left a few notes / improvements that could be beneficial for end users imo.
And a few general things that may be worth checking in another PR:
- Can we try changing the setting:
DisableCompression bool
to false in the k8s client config?
I'd expect it to be slower if we put it to true (disabling the compression) because the network latency would increase, but that would be interesting to test? (maybe even as a config 😅 with default values) - According to this profile (one the "3rd minute", since it's a minute per minute, and I imagine that was during the mongo insertion "step")
We spent about half of the CPU time (which i understand, is not the most significant part of the wall time) in garbage collection, and a lot of time copying data to mongo.
Is there a way we could pre allocate some of the buffers (and reuse that buffer instead of creating a new one for everything?) - This profile (a bit earlier in the process, the k8s api fetching part)
shows that we Unmarshal() a lot (that would makes sense, we have GB of data coming through there on large cluster). But I don't think we need to process it, do we? We are just forwarding it to mongo as is?
(I'm unsure, for example, ifitem, ok := obj.(*rbacv1.RoleBinding)
convertion/type assertion makes an allocation because it's a "complex" type? And we don't really need it because we just forward the raw json to mongo in any case?)
I mean: We do K8S json api => parse json => copy to object (via theStoreConverter
) => encode bson => send to mongo. Could we (maybe not all case, some have processing steps in there) decode to the wanted type, with annotation for both bson and json and avoid a copy?
It looks like we could save like 30-45 seconds maybe (both in GC time and time spent on unmarshalling) there?
edznux-dd
approved these changes
Oct 19, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a number of changes to optimize the creation of the graph and speed up ingest:
Total runtime for a cluster of 25k pods is 45mins -> 6mins. Graph creation time 35mins -> 30secs
It also fixes a number of minor bugs around telemetry and logging discovered during the performance testing.