mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Merge pull request #67948 from wojtek-t/use_buffers_in_kube_proxy
Automatic merge from submit-queue (batch tested with PRs 66577, 67948, 68001, 67982). If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md. Reduce amount of allocations in kube-proxy Follow up from https://github.com/kubernetes/kubernetes/pull/65902
This commit is contained in:
@@ -217,11 +217,12 @@ type Proxier struct {
|
||||
ipGetter IPGetter
|
||||
// The following buffers are used to reuse memory and avoid allocations
|
||||
// that are significantly impacting performance.
|
||||
iptablesData *bytes.Buffer
|
||||
natChains *bytes.Buffer
|
||||
filterChains *bytes.Buffer
|
||||
natRules *bytes.Buffer
|
||||
filterRules *bytes.Buffer
|
||||
iptablesData *bytes.Buffer
|
||||
filterChainsData *bytes.Buffer
|
||||
natChains *bytes.Buffer
|
||||
filterChains *bytes.Buffer
|
||||
natRules *bytes.Buffer
|
||||
filterRules *bytes.Buffer
|
||||
// Added as a member to the struct to allow injection for testing.
|
||||
netlinkHandle NetLinkHandle
|
||||
// ipsetList is the list of ipsets that ipvs proxier used.
|
||||
@@ -369,6 +370,7 @@ func NewProxier(ipt utiliptables.Interface,
|
||||
ipvsScheduler: scheduler,
|
||||
ipGetter: &realIPGetter{nl: NewNetLinkHandle()},
|
||||
iptablesData: bytes.NewBuffer(nil),
|
||||
filterChainsData: bytes.NewBuffer(nil),
|
||||
natChains: bytes.NewBuffer(nil),
|
||||
natRules: bytes.NewBuffer(nil),
|
||||
filterChains: bytes.NewBuffer(nil),
|
||||
@@ -1357,10 +1359,7 @@ func (proxier *Proxier) acceptIPVSTraffic() {
|
||||
|
||||
// createAndLinkeKubeChain create all kube chains that ipvs proxier need and write basic link.
|
||||
func (proxier *Proxier) createAndLinkeKubeChain() {
|
||||
// TODO: Filter table is small so we're not reusing this buffer over rounds.
|
||||
// However, to optimize it further, we should do that.
|
||||
filterBuffer := bytes.NewBuffer(nil)
|
||||
existingFilterChains := proxier.getExistingChains(filterBuffer, utiliptables.TableFilter)
|
||||
existingFilterChains := proxier.getExistingChains(proxier.filterChainsData, utiliptables.TableFilter)
|
||||
existingNATChains := proxier.getExistingChains(proxier.iptablesData, utiliptables.TableNAT)
|
||||
|
||||
// Make sure we keep stats for the top-level chains
|
||||
|
||||
Reference in New Issue
Block a user