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
preallocate memory #4820
preallocate memory #4820
Conversation
Signed-off-by: Florian Lehner <dev@der-flo.net>
Signed-off-by: Florian Lehner <dev@der-flo.net>
@florianl: This PR has multiple commits, and the default merge method is: merge. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Welcome @florianl! |
Hi @florianl. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
If this results in a performance improvement, could you please provide some example test cases that demonstrate the optimization? You can refer to #4810 as an example, the PR description does a good job of explaining the optimization. |
I'm not sure if it is worth including a benchmark in this PR. But to showcase the performance improvement, I did use the following code:
On my machine the results for
To compare it with the results from
So this trivial change reduces the ns/op (from 54318 to 35118) and allocs/op (from 12 to 1). |
Thanks! |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: florianl, natasha41575 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 |
What this PR does / why we need it:
Preallocate memory instead of enforcing an incremental growth. This will result in less work for the garbage collector.