-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Optimise generate ec2 #4199
Optimise generate ec2 #4199
Conversation
Welcome @aidy! |
/assign @gjtempleton |
Thanks for the PR! I don't suppose you have any metrics on what the memory improvements when using this approach are? |
func TestUnmarshalProductsResponse(t *testing.T) { | ||
body := ` |
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.
Can we add a test for an invalid json response as well as valid?
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.
I'll see what I can knock up
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.
I've added some tests for invalid json (and fixed a bug in the process). Shout if you'd like me to rebase them down.
It's pretty hacky, but I used https://gist.github.com/aidy/52ba395599be28bcdd04d4469d6f958a Using ReadAll/Unmarshal had a final output footprint of: Proposed mechanism results in: |
8a36c5a
to
504ecb4
Compare
Thanks for the tests. @mwielgus could you kick off the pending GH workflows please just to be sure? Docs for that are here. |
Refactor to allow for optimisation
504ecb4
to
e1dc0af
Compare
I'd intended this as two commits, to demonstrate that there was no functional change involved with this optimisation. |
Yup, that makes good sense! Lets keep it as is. |
"github.com/aws/aws-sdk-go/aws/ec2metadata" | ||
"github.com/aws/aws-sdk-go/aws/endpoints" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"io" | ||
"io/ioutil" |
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.
Looks like we no longer use this import, can you please remove it as it'll cause tests to fail otherwise.
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.
Ah, must have changed between rebasing. Otherwise goimports would have fixed it for me. I'll sort that now.
The pricing json for us-east-1 is currently 129MB. Currently fetching this into memory and parsing results in a large memory footprint on startup, and can lead to the autoscaler being OOMKilled. Change the ReadAll/Unmarshal logic to a stream decoder to significantly reduce the memory use.
e1dc0af
to
1177ee0
Compare
Thanks for that. I've done a manual run of the Github /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aidy, gjtempleton The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
cluster-autoscaler v1.21.1 includes: kubernetes/autoscaler#4199 This should mean we can revert to the default memory requirements.
cluster-autoscaler v1.21.1 includes: kubernetes/autoscaler#4199 This should mean we can revert to the default memory requirements.
The pricing json for us-east-1 is currently 129MB. Currently fetching
this into memory and parsing results in a large memory footprint on
startup, and can lead to the autoscaler being OOMKilled.
Change the ReadAll/Unmarshal logic to a stream decoder to significantly
reduce the memory use.
Should hopefully address #3506