cisco / senml

Tool to convert senml between formats and act as gateway server to other services
BSD 2-Clause "Simplified" License
39 stars 15 forks source link

CBOR support uses `go-codec` which adds bloat to the binary #22

Open drasko opened 5 years ago

drasko commented 5 years ago

As noted here: https://github.com/ugorji/go/issues/295

ugorji commented 5 years ago

See https://github.com/ugorji/go/issues/295#issuecomment-490082196

ugorji commented 5 years ago

Also see https://github.com/ugorji/go#managing-binary-size

fluffy commented 5 years ago

So should we add something to the instructions to tell people about how to turn off fast-path or what is your suggestion on this?

ugorji commented 5 years ago

It's your call. See https://github.com/ugorji/go#managing-binary-size

We have trimmed it down from 11MB to 5.7MB, by default. If that is still much, you can get it down to 2.9MB by using the notfastpath tag (but you sacrifice some performance as noted).

You can put that in your instructions or in your build script or something. Or you can just leave alone be if 50% savings is good enough for you. I think it is.

drasko commented 5 years ago

@fluffy I was capable to compress binary significantly with strip and then upx. I need to see if these tools are smart enough to remove unused portions of code (I am also using goweight to see what has been compiled in).

I think one solution might be making lightweight Go CBOR implementation (I have one in C, and it does not look so difficult to make, but will take some time). But I am not sure that even that in the end would be better than just having @ugorji 's implementation without fastpath.

ugorji commented 5 years ago

@fluffy @drasko Can you please take capture sizes with the latest code (that includes https://github.com/ugorji/go/commit/a2154fa654b442129cbf9b314e2893a6a22bfff8) and capture sizes before strip/upx, and then with strip/upx. I would like to see how much space these are taking now.

Thanks.