ogen icon indicating copy to clipboard operation
ogen copied to clipboard

perf: zap library leaking into binaries

Open ayuhito opened this issue 1 year ago • 1 comments

What version of ogen are you using?

v1.1.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

This is an extremely minor bug, but it's worth noting down if anyone wants to look into it.

I ran gsa on my API binaries when I noticed that zap was being imported into my project. I think it's leaking into the API binaries via the ogen/jsonschema library (not sure) and adding ~40kb to all binaries if you do not use zap.

https://github.com/ogen-go/ogen/blob/e147d5e6d100f056023a7ac3df012928e433bc04/jsonschema/external.go#L57

It's not high priority, but I think any optimizations like this will help in resource constrained environments.

What did you expect to see?

zap should not be present in the library.

What did you see instead?

image

ayuhito avatar May 11 '24 21:05 ayuhito

It seems that generated code imports github.com/ogen-go/ogen/middleware https://github.com/ogen-go/ogen/blob/d1f597e7f71c980c19a7e4f221c1320ae00bcf74/examples/ex_petstore/oas_middleware_gen.go#L6

github.com/ogen-go/ogen/middleware imports github.com/ogen-go/ogen/openapi https://github.com/ogen-go/ogen/blob/d1f597e7f71c980c19a7e4f221c1320ae00bcf74/middleware/middleware.go#L8

github.com/ogen-go/ogen/openapi imports github.com/ogen-go/ogen/jsonschema https://github.com/ogen-go/ogen/blob/d1f597e7f71c980c19a7e4f221c1320ae00bcf74/openapi/api.go#L6

Not sure if we can fix it without breaking v1 compatibility.

ghost avatar May 15 '24 02:05 ghost