Skip to content

Only detecting stale connections for UDP ports in kube-proxy#83208

Merged
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
robscott:endpointslice-proxy-staleconn-perf
Oct 3, 2019
Merged

Only detecting stale connections for UDP ports in kube-proxy#83208
k8s-ci-robot merged 1 commit intokubernetes:masterfrom
robscott:endpointslice-proxy-staleconn-perf

Conversation

@robscott
Copy link
Copy Markdown
Member

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
The detectStaleConnections function in kube-proxy is very expensive in terms of CPU utilization. The results of this function are only actually used for UDP ports. This adds a protocol attribute to ServicePortName to make it simple to only run this function for UDP connections. For clusters with primarily TCP connections this can improve kube-proxy performance by 2x.

Special notes for your reviewer:
Sorry for the huge size of this PR. The actual functional code changes are rather small, but unfortunately the vast majority of tests did not specify a protocol, or if they did, it was inconsistently. To make this work I added protocol to the ServicePortName type. This resulted in fairly minimal changes to the codebase, but unfortunately resulted in lots of repetitive changes to tests that were rarely specifying a protocol.

I also considered allowing the EndpointChangeTracker to access the ServiceMap data structure, but that felt dirty and more bug prone. I also considered adding a new data structure to EndpointChangeTracker that would map ServicePortNames to their protocols. As far as I can tell, this would have required a similar amount of changes to tests as well unfortunately. Open to investigating that or other options if this feels too bad.

Does this PR introduce a user-facing change?:

Significant kube-proxy performance improvements for non UDP ports.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

/sig network
/cc @freehan
/priority important-longterm

The detectStaleConnections function in kube-proxy is very expensive in
terms of CPU utilization. The results of this function are only actually
used for UDP ports. This adds a protocol attribute to ServicePortName to
make it simple to only run this function for UDP connections. For
clusters with primarily TCP connections this can improve kube-proxy
performance by 2x.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/network Categorizes an issue or PR as relevant to SIG Network. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/ipvs labels Sep 26, 2019
@freehan
Copy link
Copy Markdown
Contributor

freehan commented Oct 3, 2019

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 3, 2019
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: freehan, robscott

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 3, 2019
@fejta-bot
Copy link
Copy Markdown

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/ipvs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants