I'd never heard of this before, so shame on me, but programs like UPX can compress my files by 80% which is totally sweet, but I have no idea what the the disadvantages are in doing this. Or even what the compressor does.

  • Website linked above doesn't say anything about dynamically linking DLLs but it mentions about compressing DESCENT 2 and about compressing Netscape 4.06. Also, it doesn't say what the tradeoffs are, only the benefits. If there weren't tradeoffs why wouldn't my linker compress the file?

If I have an environment where I have one executable and 20-30 DLL's, some of which are dynamically loaded an unloaded fairly arbitrarily, but not in loops (hopefully), do I take a big hit in processing time decompressing these DLL's when they're used?

  • 5
    I have to downvote this question. You link a website which explains EXACTLY WHAT and HOW UPX works but you claim you have "no idea" what an open source compressor does or the advantages and disadvantages to it. Seems like you need to educate yourself on the subject before you can ask a question about it. – Ramhound Aug 24 '12 at 16:42
  • Did you look at the website I linked to? Does it say anything about dynamically linking DLLs? No. does it say anything about compressing DESCENT 2? Yes. Does it say anything about compressing Netscape 4.06? Yes. – Peter Turner Aug 24 '12 at 16:47
  • Also, it doesn't say what the tradeoffs are, only the benefits. If there weren't tradeoffs why wouldn't my linker compress the file? – Peter Turner Aug 24 '12 at 16:51
  • 1
    I imagine that there will be some performance hit. The larger the DLL and the greater the compression ratio, the larger the performance hit (at least that's what I'd assume - I don't know specific numbers but I'm sure you could set up some tests to run to see). – FrustratedWithFormsDesigner Aug 24 '12 at 17:00

Does executable compression hurt performance?

As with most performance questions, I suspect the answer is, "Do some performance tests / profiling for yourself and see what you find out."

  • Performance might be worse, because you have the run-time overhead of decompression.
  • Performance might be better, because you have less data that you need to read off of the hard drive.
  • Performance might be worse, because the executable must be read and decompressed into memory, instead of letting the OS map virtual memory space directly to the on-disk executable, which would let it more easily load pages on demand, share them between multiple executable instances, and discard them if there's memory pressure.

Wikipedia has a more in-depth discussion of the advantages and disadvantages of executable compression.

Why don't linkers automatically use executable compression?

There are probably two main reasons:

  • It adds complexity, and in programming, complexity is Bad™.
  • It just doesn't give much benefit. Saving space under c:\Program Files isn't of much use; modern hard drives are so big that your exe space is a non-issue. Download speeds are important, but your installer already compresses your exes, so compressing them again with UPX won't make a substantial difference. If you're trying to make a portable (no-installation-needed) executable, then UPX could help, but that's something of a niche market.
  • It's also not always lossless. Several popular compressors fail miserably at TLS callbacks, which is quite a bummer if you ever happen to have them. If you ever incorporate one into your build process, make sure you test the resulting binary. – Lars Viklund Aug 30 '12 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.