LWN.net Logo

Real-life optimization work

Real-life optimization work

Posted Nov 3, 2005 10:03 UTC (Thu) by nix (subscriber, #2304)
In reply to: Real-life optimization work by smoogen
Parent article: All hail the speed demons (O'Reillynet)

Indeed. A lot of this is increased alignment constraints, but in binaries as opposed to in memory a pile is caused directly by increased address sizes. e.g.:

-rwxr-xr-x  1 nix users 1165752 Nov  3 09:55 32/libcrypto.so.0.9.7
-rwxr-xr-x  1 nix users 1398112 Nov  3 09:55 64/libcrypto.so.0.9.7
That's two stripped UltraSPARC binaries, both built with -mcpu=ultrasparc (thus using almost identical instructions), one built with -m32 and one with -m64 with a biarch GCC. Major differences are thus alignment of data (25Kb size difference) code (20Kb size difference)... and relocations (100Kb difference: the 64-bit relocation sections are twice the size, because they're basically big tables of addresses and all the addresses have doubled in size).


(Log in to post comments)

Real-life optimization work

Posted Nov 3, 2005 19:55 UTC (Thu) by mcm (guest, #31917) [Link]

i guess the relocations could be compressed, as they can probably be represented as 32-bit offsets to a 64-bit base.

Real-life optimization work

Posted Nov 4, 2005 13:22 UTC (Fri) by nix (subscriber, #2304) [Link]

Indeed they could be compressed, but I think you might need a new relocation type for 64+32 base+offset... (I'm not sure and don't have the specs here).

Real-life optimization work

Posted Nov 5, 2005 3:11 UTC (Sat) by vonbrand (subscriber, #4458) [Link]

Sorry, but comparing the size of the binaries is useless. Use size(1) for that. Also, from what I understand, on SPARC 64-bit binaries are much larger due to larger constants (pointers, integers, ...) all over the place.

Besides, what is the point? To get anything running on an 8-bit machine was a challenge, lots of things you take for granted today weren't even the stuff of wet dreams then. You also have to remember that today the expensive part of the mix is people, not machine. Sure, one could develop mean and lean applications doing most of what today's software does. With enough care, you could even figure out how to include just the features people really use, and shave off quite a bit more. But the development would be a whole lot more expensive, just for letting a few MiB of RAM lay around unused for a change.

Real-life optimization work

Posted Nov 7, 2005 0:18 UTC (Mon) by nix (subscriber, #2304) [Link]

I size(1)d them, of course; I just didn't want to spray the result all over the comments page.

And, yes, I'd agree that normally shaving bytes off things isn't worth it: however, with that in mind I spent this weekend shaving a few bytes off one data structure in one program and reducing the number of instances of that data structure --- and reducing the program's peak memory consumption from many gigabytes to a few hundred Mb.

But microoptimizations without major results, or pervasive ones, are indeed generally not worth it.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds