Skip to content

OpenAPI/Swagger parsing is (?) performance bottleneck #3670

@justinsb

Description

@justinsb

I was wondering why running kustomize (& kpt) is not effectively instant, and I tracked down a large performance bottleneck - initializing the OpenAPI / parsing the swagger.

I believe this is the most significant constant-overhead for kustomize - obviously on very large kustomizations the data manipulation will eventually dominate.

I sent #3669 which adds a benchmark to quantify the impact; based on that it takes about 900ms to json parse the swagger itself; it takes about 20ms to un-gzip from the data embedded into the binary. These roughly tally with the performance overhead I see in the real world.

This particularly matters for e.g. kpt, where a kpt setter which uses kyaml also takes at least 1 second to run.

I think it would be interesting to cache the deserialized form.

But there's also some low-hanging fruit, e.g. the swagger UnmarshalJSON code calls json.Unmarshal twice over the same data (once for SwaggerProps, once for VendorExtensible). But that only gets us 2x, whereas caching (I'd SWAG) could be 100-1000x.

Metadata

Metadata

Assignees

Labels

area/kyamlissues for kyamlarea/openapiIssues to OpenAPI in kyamlkind/regressionCategorizes issue or PR as related to a regression from a prior release.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions