Hi team, I thought that I should share the results of a small experiment… We should consider running upx
over our compiled binaries. This will add about ~10mins to the build but should decrease the size of what we ship by at least 70%.
$ cp $GOPATH/bin/juju* /tmp
$ cd /tmp
$ upx -9 juju*
Ultimate Packer for eXecutables
Copyright (C) 1996 - 2018
UPX 3.95 Markus Oberhumer, Laszlo Molnar & John Reiser Aug 26th 2018
File size Ratio Format Name
-------------------- ------ ----------- -----------
100954112 -> 27944028 27.68% linux/amd64 juju
52021592 -> 15768984 30.31% linux/amd64 juju-blobstore-cleanup
3239584 -> 1231776 38.02% linux/amd64 juju-bridge
8822784 -> 3396680 38.50% linux/amd64 jujuc
124768256 -> 33763772 27.06% linux/amd64 jujud
51984728 -> 15762660 30.32% linux/amd64 juju-force-upgrade
52091224 -> 15795124 30.32% linux/amd64 juju-list-blobstore
85049344 -> 22593872 26.57% linux/amd64 juju-metadata
-------------------- ------ ----------- -----------
478931624 -> 136256896 28.45% [ 8 files ]
Yes, the files are still perfectly fine. Naturally, they need to be decompressed to execute them - so perhaps it’s not worth it for the clients. But the agents would certainly benefit from reduced file sizes in my opinion.
A blog post about using UPX with Go projects. (We already use -ldflags "-w -s"
to strip debugging info from release builds)