-
Notifications
You must be signed in to change notification settings - Fork 2.3k
perf: Add an option to skip OpenAPI schema initialization #5932
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
base: master
Are you sure you want to change the base?
Conversation
|
|
|
Welcome @iliakonnov! |
|
Hi @iliakonnov. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: iliakonnov The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
This PR introduces a new
skipfield to theopenapimap in the kustomization file.Problem
When using Kustomize as a library,
Kustomizer.Runcallsopenapi.SetSchemaon every execution. In high-frequency scenarios where the same schema is used repeatedly, this leads to a significant performance bottleneck due to redundant schema compilation.In our use case, we call
Kustomizer.Runthousands of times. Flame graph analysis showed that schema compilation was a major contributor to the overall execution time.Solution
By setting
openapi.skiptotrue, users can now bypass the call toopenapi.SetSchemainsideKustomizer.Run. This allows library consumers to initialize the schema once at application startup and reuse it for all subsequent runs.Example workflow:
openapi.SetSchema(...).kustomization.yaml, add theskipfield:kustomizer.Run()as usual.Result
This change dramatically improves performance in our scenario, reducing the total processing time from 30 minutes to 9 minutes.
Next Steps and Design Alternatives
I've submitted this patch as a minimal implementation to start a discussion and validate the approach. I'm keen to hear your feedback and I'm ready to make adjustments.
Here are a few alternatives I've considered:
kustomization.yamlformat, we could add a new field directly to theKustomizerstruct (e.g.,Kustomizer.SkipOpenAPISchema). This would make the feature available only when Kustomize is used as a library, which is the primary use case for this optimization. I'm happy to implement it this way if you prefer.skipis a placeholder. A more descriptive name likeusePreconfiguredSchemaorbuilt-inmight be better. I don't have a strong preference and am open to suggestions.My main goal is to get early feedback on whether this direction for performance improvement is welcome before investing more time.