3 ms·
> I didn’t mention this because it doesn’t improve such a small program, but you can also try UPX and other executable compressors if you are working with a muc
by nickcw 7y ago
> I didn’t mention this because it doesn’t improve such a small program, but you can also try UPX and other executable compressors if you are working with a much larger application.
I don't recommend this as it will increase the memory used by your program which is usually more important than how much disk space it takes up.
OSes only page in the bits of the executable that is actually run, however when upx decompresses the binary it has to load it all into RAM. That RAM can be swapped out but for a normal executable backed by a file the kernel would just drop pages from the file so no write IO needed.
In my tests with rclone, using upx made the binary 31% of the size, but made it use 42% more RAM. YMMV!
- lifthrasiir 7y agoWhile you are technically correct, nowadays the executable file size is minuscule compared to the available memory. Since upx uses the UCL algorithm which requires no additional memory besides the target buffer AFAIK, the memory increase can only be attributed to the original file size---I think rclone weighs about 20 MBs, so it is probably the case that rclone unusually consumes less memory! :p The real problem with upx is the invocation latency, which is a big blocker when your program starts a lot (common for CLIs). Executable compression has been much more common in Windows because the download size matters there and programs tend to last much longer.
- ChrisSD 7y agoI've found that UPX triggers AntiVirus programs more often than uncompressed binaries on Windows.