-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Performance degradation starting with v3.8.6 #4100
Comments
@shapirus: This issue is currently awaiting triage. SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the The Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Attaching a Dockerfile that can be used to reproduce the test run described above by building it. |
I'm linking the release notes for kustomize v3.8.6 that might help us narrow down what caused such a big decline in performance: https://github.com/kubernetes-sigs/kustomize/releases/tag/kyaml%2Fv0.9.3 One possible culprit is 119d7ca, which adds OpenAPI parsing (known to be very slow) when checking if a resource is namespaceable. |
There is a futher performance degradation after updating from Kustomizer 4.1.2 to 4.2.0. My pipeline, which calls I exclusively use kustomize for its configMapGenerators and secretGenerators. I don't use any other features. |
Bingo! You've found the culprit. In
With this change, the duration of my pipeline went down from 18.5 seconds to just 4.5 seconds. Obviously, this is no real solution. Unfortunately, I am not a go developer and have almost no idea what I am doing here. But at least we've successfully identified the bottleneck. |
I've replaced my dummy implementation with the hardcoded list that was used before it has been replaced in 119d7ca:
My pipeline is still just as fast as with my previous dummy: Still 4.5 seconds for just over 20 calls to I guess this is good enough for my use cases, so I will use my hacked executable for the time being. |
I guess that the parsing of the huge openapi-schema (json) takes most of the time. Maybe it would help to convert the json to gop (using https://pkg.go.dev/encoding/gob) at build-time, so that kustomize could read the pre-converted gop-file at runtime? Edit: Instead of using gop or protobuf, maybe this is a good use-case for code generation (https://blog.golang.org/generate). This way we could generate a go-array of non-namespaced kinds and then include the generated list in Sorry for the comment spam. |
Another option is to re-add a hardcoded list of namespaceable resources. We may be able to automatically generate it (so that we don't have to manually maintain the list) with the scripts that fetch OpenAPI data. However, OpenAPI parsing being a bottleneck is a common theme so using gop, proto, or some other type of encoding scheme that is quicker to parse is probably a good idea. I would gratefully accept any PRs that are able to achieve an improvement in OpenAPI parsing time (with benchmark tests). One requirement however would be that the public kyaml interface would have to stay the same, as there are library consumers outside of kustomize that use it. I am seriously considering submitting a PR to revert the commit that removed the hardcoded list for the sake of performance. |
awesome, thank you, I will try to test it tomorrow. |
I can confirm that the issue is now resolved. With kustomize built from HEAD:
|
There is an improvement with Kustomize 4.4.0, but not as large as I expected. I just tested the new kustomize release 4.4.0 against 4.3.0 and also against my hack as decribed in #4100 (comment). My pipeline consists of about 20 calls to Result:
This is strange, because I've reviewed #4152 and it does essentially the same as my hack. Maybe there is a new performance degradation introduced with 4.4.0? |
kubernetes-sigs/kustomize#4100 This version mismatches that embedded with kubectl, but let's assume that it will make it to Kubernetes 1.23
We have a similar pipeline and I get the following results:
|
Unfortunately, 4.4.0, while being much faster on the simple test case that I described here, is still much slower than, for example, 3.5.4 on a more complex (but still not too complex, just a few resources included) setup, and is comparable to 3.9.4, for example. I still have to keep my argocd at kustomize v3.5.4. I will create a test case that demonstrates the difference later and reopen this issue, or open a new one. |
@natasha41575 I have commented on that issue as well. Sounds like the discussion should be moved back here, but that's up to you. |
For those who come here from search results, it's resolved by #5076, see #4569 (comment). |
Starting with v3.8.6, a serious performance degradation is observed even on a very basic setup. Version 3.8.5 (and older) was fine.
Demonstration:
kustomization.yaml
service.yaml
I performed a test run with versions 3.8.5, 3.8.6, 3.8.7, 3.8.8, 4.2.0. While v3.8.5 is able to build the manifest in about 35 ms, v3.8.6 and v3.8.7 spend about 850 ms, and then starting with v3.8.8 and up to the latest v4.2.0 it takes about one second.
Output is identical in each run, so I filtered it out to make it easier to read.
It must be noted that I do not observe any performance degradation on big setups, when bases and more resources are included. Kustomize apparently spends that extra second once on startup, and then works fast processing everything. It is still a problem in my case, however, because I have a lot of microservices that have to be processed using multiple invocations of kustomize.
Platform
Linux/amd64.
The text was updated successfully, but these errors were encountered: