mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
proxier/iptables: reuse the same variable for endpointchains for better memory consumption
Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
parent
55881093d8
commit
4c8b190372
@ -993,6 +993,11 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
// slice = append(slice[:0], ...)
|
// slice = append(slice[:0], ...)
|
||||||
endpoints := make([]*endpointsInfo, 0)
|
endpoints := make([]*endpointsInfo, 0)
|
||||||
endpointChains := make([]utiliptables.Chain, 0)
|
endpointChains := make([]utiliptables.Chain, 0)
|
||||||
|
readyEndpoints := make([]*endpointsInfo, 0)
|
||||||
|
readyEndpointChains := make([]utiliptables.Chain, 0)
|
||||||
|
localReadyEndpointChains := make([]utiliptables.Chain, 0)
|
||||||
|
localServingTerminatingEndpointChains := make([]utiliptables.Chain, 0)
|
||||||
|
|
||||||
// To avoid growing this slice, we arbitrarily set its size to 64,
|
// To avoid growing this slice, we arbitrarily set its size to 64,
|
||||||
// there is never more than that many arguments for a single line.
|
// there is never more than that many arguments for a single line.
|
||||||
// Note that even if we go over 64, it will still be correct - it
|
// Note that even if we go over 64, it will still be correct - it
|
||||||
@ -1396,10 +1401,10 @@ func (proxier *Proxier) syncProxyRules() {
|
|||||||
// 1. all endpoints that are ready and NOT terminating.
|
// 1. all endpoints that are ready and NOT terminating.
|
||||||
// 2. all endpoints that are local, ready and NOT terminating, and externalTrafficPolicy=Local
|
// 2. all endpoints that are local, ready and NOT terminating, and externalTrafficPolicy=Local
|
||||||
// 3. all endpoints that are local, serving and terminating, and externalTrafficPolicy=Local
|
// 3. all endpoints that are local, serving and terminating, and externalTrafficPolicy=Local
|
||||||
readyEndpointChains := make([]utiliptables.Chain, 0, len(endpointChains))
|
readyEndpointChains = readyEndpointChains[:0]
|
||||||
readyEndpoints := make([]*endpointsInfo, 0, len(allEndpoints))
|
readyEndpoints := readyEndpoints[:0]
|
||||||
localReadyEndpointChains := make([]utiliptables.Chain, 0, len(endpointChains))
|
localReadyEndpointChains := localReadyEndpointChains[:0]
|
||||||
localServingTerminatingEndpointChains := make([]utiliptables.Chain, 0, len(endpointChains))
|
localServingTerminatingEndpointChains := localServingTerminatingEndpointChains[:0]
|
||||||
for i, endpointChain := range endpointChains {
|
for i, endpointChain := range endpointChains {
|
||||||
if endpoints[i].Ready {
|
if endpoints[i].Ready {
|
||||||
readyEndpointChains = append(readyEndpointChains, endpointChain)
|
readyEndpointChains = append(readyEndpointChains, endpointChain)
|
||||||
|
Loading…
Reference in New Issue
Block a user