k8s: In endpoint parsing reuse Backend and Ports for each address#40987
Merged
joamaki merged 1 commit intocilium:mainfrom Aug 8, 2025
Merged
Conversation
Contributor
Author
|
/test |
Contributor
Author
|
Marked for v1.18 backports as this is a significant improvement in memory use for large clusters and the changes are small. |
Contributor
Author
|
/test |
marseel
requested changes
Aug 7, 2025
Since the ports are the same for everything in the EndpointSlice just prepare the 'Ports' map once. Similarly for Backend as the data is the same for each address allocate it just once. To further reduce allocations pre-allocate the hash maps. Benchmark results with https://github.com/joamaki/cilium-lb-load-test: Current `main` (image tag deaee71): Creating 1000 Services and EndpointSlices (30 backends per service, 30000 in total) in namespace cni-load-test... Finished creating resources. Waiting 10 seconds to settle... Recording memory usage RSS (kB): 257724.0 (diff 55952.0) Reachable kB: 42516.21875 Allocations: 3875906 Allocated kB: 169957.71875 CPU time seconds: 1.5099999999999998 This commit: Creating 1000 Services and EndpointSlices (30 backends per service, 30000 in total) in namespace cni-load-test... Finished creating resources. Waiting 10 seconds to settle... Recording memory usage RSS (kB): 258784.0 (diff 50344.0) Reachable kB: 37336.3984375 Allocations: 3772102 Allocated kB: 162521.7578125 CPU time seconds: 1.4699999999999989 Roughly ~10% less memory allocated and reachable. Signed-off-by: Jussi Maki <jussi@isovalent.com>
485d762 to
4516432
Compare
Contributor
Author
|
/test |
10 tasks
This file contains hidden or 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
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.
Since the ports are the same for everything in the EndpointSlice just prepare the 'Ports' map once.
Similarly for Backend as the data is the same for each address allocate it just once.
To further reduce allocations pre-allocate the hash maps.
Benchmark results with https://github.com/joamaki/cilium-lb-load-test:
Current
main(image tag deaee71):This commit:
Roughly ~10% less memory allocated and reachable.