I performed the steps in the article and reduced the output binary size from ~35 MB for raw go build to around 29 MB for go build with the ldflags all the way down to 8.3 MB for compressed with upx.
Really impressive results.
I performed the steps in the article and reduced the output binary size from ~35 MB for raw go build to around 29 MB for go build with the ldflags all the way down to 8.3 MB for compressed with upx.
Really impressive results.
I hadn't tested the startup times of the upx binary before, so I just did by running `time $binary_name --help`. For my binary, this should print a simple help message and quit.
Big: 0.04s user 0.01s system 101% cpu 0.054 total
Med: 0.04s user 0.01s system 99% cpu 0.048 total
Sm : 0.14s user 0.02s system 99% cpu 0.163 total
So you're right - it makes execution time take about 3x as long. However, in my case, 3x slower is a fine trade off to make.
35 MB is huge! Are there any assets inside the binary?
For context, 35MB is two and a half boxes of high-density floppy disks. There were whole operating systems, complete with applications, smaller than that.
go version go1.14.4 darwin/amd64
Looks like the Linux and Darwin versions of the binaries are only a few hundred kb different.
Native Android doesn't need such big sizes.
But to answer your question, you're going to see some performance improvements if your binary can fit into lower levels of the CPU cache.
Kdb+/q for example is less than 700kb, which mean that the entire thing can fit into the L1 instruction cache on high end server CPUs. And that size is even more impressive considering its only dynamically linked to libc and libpthread.
This small size contributes to the out of this world performance the system has. And remember that's the language and the time series db.
(The program we at Google use just to build our bloated programs is itself 180MB.)
But also, since this is client side code, a smaller download means smaller utilities on client machines. Which is nice.