tianon / gosu

Simple Go-based setuid+setgid+setgroups+exec
Apache License 2.0
4.69k stars 312 forks source link

Add upx to Docker build to compress compat bins #70

Closed abtreece closed 4 years ago

abtreece commented 4 years ago

The Ultimate Packer for eXecutables (upx) is a really good way to compress binaries...

        File size         Ratio      Format      Name
   --------------------   ------   -----------   -----------
   2404352 ->    916880   38.13%   linux/amd64   gosu-amd64
   2490368 ->    861176   34.58%   linux/arm64   gosu-arm64
   2228224 ->    869936   39.04%    linux/arm    gosu-armel
   2162688 ->    862008   39.86%    linux/arm    gosu-armhf
   2084864 ->    872784   41.86%   linux/i386    gosu-i386
   2424832 ->    887088   36.58%   linux/ppc64   gosu-ppc64
   2424832 ->    879236   36.26%  linux/ppc64le  gosu-ppc64el
upx: gosu-s390x: UnknownExecutableFormatException
   --------------------   ------   -----------   -----------
  16220160 ->   6149108   37.91%                 [ 7 files ]

The s390x format is unsupported currently.

Bump version to 1.12 because of changes to binaries

tianon commented 4 years ago

While smaller binaries are interesting, I would definitely have to echo https://github.com/kubernetes/kubernetes/pull/28265#issuecomment-230124309 here:

What is the goal? UPX has downsides:

  • demand-paging is impossible, resulting in higher overall memory usage
  • page-sharing is impossible (e.g. hyperkube), resulting in higher overall memory usage

With that in mind, our current binaries are ~2-3MB each, which IMO is pretty reasonable for a Go binary. If you're looking for something explicitly tiny, su-exec was created with that exact goal in mind: https://github.com/ncopa/su-exec

Why reinvent gosu?

This does more or less exactly the same thing as gosu but it is only 10kb instead of 1.8MB.

(Just keep in mind it hasn't seen a release with https://github.com/ncopa/su-exec/commit/212b75144bbc06722fbd7661f651390dc47a43d1 included yet)

abtreece commented 4 years ago

Ok. Fair enough.