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

openapi-aggregation: speed up merging from 1 sec to 50-100 ms #71223

Merged

Conversation

sttts
Copy link
Contributor

@sttts sttts commented Nov 19, 2018

This PR avoids swagger spec cloning by non-source-mutating merging. It uses a mutating walker that locally clones minimal substructures.

Speedup: >>10

Considerably reduced the CPU load in kube-apiserver while aggregating OpenAPI specifications from aggregated API servers.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 19, 2018
@roycaihw
Copy link
Member

Great! The idea looks good to me. Spec cloning makes up ~98% of the time when we do spec merging.

We need to unit test the cloning. I see kube-openapi has a decent amount of unit test covering spec merging. Maybe that's enough

@sttts sttts changed the title openapi-aggreation: speed merging from 1 sec to 50-100 ms openapi-aggreation: speed up merging from 1 sec to 50-100 ms Nov 22, 2018
@sttts sttts changed the title openapi-aggreation: speed up merging from 1 sec to 50-100 ms openapi-aggregation: speed up merging from 1 sec to 50-100 ms Dec 9, 2018
@sttts sttts force-pushed the sttts-openapi-aggreation-without-clone branch 2 times, most recently from 3a0132a to 9c7b6cb Compare December 11, 2018 06:57
@mbohlool
Copy link
Contributor

This is a change in vendor folder, please close this in favor of the other PR for less confusion. I was looking for my comments on the other PR here :)

@sttts sttts force-pushed the sttts-openapi-aggreation-without-clone branch 2 times, most recently from c66f1c8 to 079c1b0 Compare February 1, 2019 13:02
@sttts sttts added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. labels Feb 1, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Feb 1, 2019
@sttts sttts added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Feb 1, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Feb 1, 2019
@sttts sttts removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Feb 1, 2019
@sttts sttts force-pushed the sttts-openapi-aggreation-without-clone branch from 7618d5c to 7f9bb8e Compare February 8, 2019 17:16
@sttts sttts force-pushed the sttts-openapi-aggreation-without-clone branch from 7f9bb8e to 19506e4 Compare February 8, 2019 20:31
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 8, 2019
@liggitt
Copy link
Member

liggitt commented Feb 8, 2019

something is up with the godeps changes:

Your Godeps.json is different:
--- Godeps/Godeps.json	2019-02-08 20:33:07.190360977 +0000
+++ /tmp/gopath.tGCkZA/src/k8s.io/kubernetes/Godeps/Godeps.json	2019-02-08 20:47:27.121379369 +0000
@@ -1679,7 +1679,7 @@
 		},
 		{
 			"ImportPath": "github.com/go-sql-driver/mysql",
-			"Comment": "v1.3",
+			"Comment": "v1.3.0",
 			"Rev": "a0583e0143b1624142adab07e0e97fe106d99561"
 		},
 		{
@@ -2348,6 +2348,7 @@
 		},
 		{
 			"ImportPath": "github.com/inconshreveable/mousetrap",
+			"Comment": "v1.0",
 			"Rev": "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
 		},
 		{
@@ -2429,12 +2430,10 @@
 		},
 		{
 			"ImportPath": "github.com/lib/pq",
-			"Comment": "go1.0-cutoff-203-g88edab0803230a",
 			"Rev": "88edab0803230a3898347e77b474f8c1820a1f20"
 		},
 		{
 			"ImportPath": "github.com/lib/pq/oid",
-			"Comment": "go1.0-cutoff-203-g88edab0803230a",
 			"Rev": "88edab0803230a3898347e77b474f8c1820a1f20"
 		},
 		{
@@ -2508,7 +2507,7 @@
 		},
 		{
 			"ImportPath": "github.com/matttproud/golang_protobuf_extensions/pbutil",
-			"Comment": "v1.0.0-2-gc12348ce28de40",
+			"Comment": "v1.0.1",
 			"Rev": "c12348ce28de40eed0136aa2b644d0ee0650e56c"
 		},

@sttts sttts force-pushed the sttts-openapi-aggreation-without-clone branch from 19506e4 to ff2547c Compare February 8, 2019 21:58
Godeps/Godeps.json Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. label Feb 9, 2019
@sttts sttts force-pushed the sttts-openapi-aggreation-without-clone branch 3 times, most recently from c702b4d to 608ca9c Compare February 11, 2019 12:06
@sttts sttts force-pushed the sttts-openapi-aggreation-without-clone branch from 608ca9c to 233178e Compare February 11, 2019 12:16
@sttts
Copy link
Contributor Author

sttts commented Feb 11, 2019

/retest

@liggitt
Copy link
Member

liggitt commented Feb 11, 2019

/retest

verified the only differences in the swagger.json file are object key order and json string escaping (no structural or value changes that would affect anything consuming the published schemas)

diff \
  <(curl -s https://raw.githubusercontent.com/sttts/kubernetes/sttts-openapi-aggreation-without-clone/api/openapi-spec/swagger.json | jq -S .) \
  <(curl -s https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json | jq -S .)

<no diff>

/lgtm
/approve
/retest

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt, sttts

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

The pull request process is described here

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 Feb 11, 2019
@k8s-ci-robot k8s-ci-robot merged commit 6912bbb into kubernetes:master Feb 11, 2019
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/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants