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

Improve 'ipSliceDifference' function memory footprint #567

Merged
merged 4 commits into from
Apr 18, 2023

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented Apr 17, 2023

Methods NsxtEdgeGateway.GetAllUnusedExternalIPAddresses and NsxtEdgeGateway.GetUnusedExternalIPAddresses perform computations based on netip.Addr package.

The internal function ipSliceDifference is used to allocate a new slice to hold the final results. However, the operations become quite expensive memory wise having big subnets in Edge Gateway. Optimizing this function reduced memory consumption twice (see example below)

Example information

One example was allocation /8 IPv4 subnet (16777213 IPs)

Before optimization 2 operations consumed such an amount of memory (getAllUnusedExternalIPAddresses - 7703.94MB)
image

After optimization 2 operations of getAllUnusedExternalIPAddresses consume such amount (after 3853.80MB vs before 7703.94MB):
image

Signed-off-by: Dainius Serplis <dserplis@vmware.com>
Signed-off-by: Dainius Serplis <dserplis@vmware.com>
Signed-off-by: Dainius Serplis <dserplis@vmware.com>
Signed-off-by: Dainius Serplis <dserplis@vmware.com>
@Didainius Didainius marked this pull request as ready for review April 17, 2023 11:53
@Didainius Didainius removed the request for review from lvirbalas April 17, 2023 11:53
Copy link
Collaborator

@adambarreiro adambarreiro left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for answering the doubts, it helped a lot.

@Didainius Didainius merged commit 35dc5da into vmware:main Apr 18, 2023
@Didainius Didainius deleted the improve-edge-memory branch April 18, 2023 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants