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

Huge dependency #1847

Open
john8329 opened this issue Apr 6, 2019 · 11 comments
Open

Huge dependency #1847

john8329 opened this issue Apr 6, 2019 · 11 comments

Comments

@john8329
Copy link

john8329 commented Apr 6, 2019

Using go 1.12, latest version of gin to date, I analysed my executable and I see that 11MB are occupied by the dependency github.com/ugorji/go/codec. Does really gin need all of this package?

@tqcenglish
Copy link

some result through goweight

@sairoutine
Copy link
Contributor

github.com/ugorji/go/codec is used to output msgpack.
It is huge because codec supports not only msgpack but also cbor, json.

It should be better we thinking to use other msgpack libraries instead of it.

@Hades32
Copy link

Hades32 commented Apr 9, 2019

Just realized just the same thing. That's ridiculously large for a hello world http server.

I would argue that MsgPack support shouldn't be part of core Gin anyway. It's not a super common format like Json. Some goes probably for github.com/golang/protobuf ~2MB...

IMHO it would make more sense to have a gin-msgpack and gin-protobuf dependency. Looking at it this would probably require making default content-type bindings and renderers plugable, but this seems to be a good idea anyway...

@ravener
Copy link

ravener commented Apr 9, 2019

i agree, those dependencies should be someway optional or as another plugin package, in most cases i don't think a user would need those dependencies.

@john8329
Copy link
Author

Good frameworks are built up in modules. As we don't expect gin to have other useful stuff like jwt, it shouldn't include by default a relatively more obscure encoding for no reason, in my own opinion.

@dmarkham
Copy link
Contributor

So go in general is just a little over the top in executable size. If we were all prioritizing saving 2MB we would be writing in rust or c.

I don't really like the build tags option either. Last thing I want to think about is all the build tags we end up adding add then having to support in the future.

Now that binding has been refactored into a nice interface. Seems like we should be able to get all none builtin encoding's moved out into something that registers itself with gin on a per app basis maybe similar to how sql drivers do it. We can do better!

@sapk
Copy link
Contributor

sapk commented Apr 14, 2019

@dmarkham the build flag is mainly to have non-breaking optimization but a system like sql drivers should be better and should not be that difficult to setup. The most difficult point would be the current select of content-type in the binding module. The rest could already be 'pluggable' but that would break reverse compat with older version and would need a v2 versioning.

@dmarkham
Copy link
Contributor

dmarkham commented Apr 15, 2019

@sapk technically I don't think msgpack / protobuff have been in a released yet. They are being proposed to be included in v1.4.0 and that is not out yet. Maybe they should be the first to use a new ''pluggable" version, vs the first to to start a trend on being excluding via tags?

With that being said, I don't feel super strongly about it, and I guess I would been better if i thought about it back when #1479 was getting talked about.

@guonaihong
Copy link
Contributor

If you remove github.com/ugorji/go/codec, it will automatically build faster for me.

@thinkerou
Copy link
Member

About the issue, I may remove binding/msgpack and binding/protobuf, etc, and render/msgpack and render/protobuf, etc. And then we may have two method to solve the change:

  1. add gin-gonic/gin-binding and gin-gonic/gin-render, it will like Modular deps for binding and render #1856
  2. not add gin-gonic/gin-binding and gin-gonic/gin-render, user realizes Binding interface and Render interface.

@thinkerou
Copy link
Member

thinkerou commented Jun 2, 2019

And gin.Context not use render.MsgPack and binding.MsgPack directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants