News for hackers. Stuff that matters.
Re:Sta.li: Static Linux by clord on Wednesday February 19, 2014 @01:42AM (#7262200)
On top of what others have said, it takes some time to dynamically load a library into an address space. There are tables that may need to be walked and updated with correct pointers. For large libraries, this can be quite measurable. A statically linked executable will be memory-mapped and then brought in lazily as the program runs. And then if executed again, everything is mapped and loaded, so there is zero delay. Compare to dynamic loading, which will require table updates again (especially with ASLR).

This is why I like to re-make my shell and associated tools static binaries — shell scripts run 10-20% faster. (lots of small programs running repeatedly)

Re:Sta.li: Static Linux by davidp on Wednesday February 19, 2014 @01:57AM (#7262251)
> it takes some time to dynamically load a library into an address space. There are tables that may need to be walked and updated with correct pointers

True, but I'd expect that to be dwarfed by the I/O time required to load even a single 4k page from disk, vs. keeping one copy of a big dynamic library like glibc loaded for the whole system, with fixups done per-process.

Good points about ASLR and static-linking frequently-exec'd-and-exited processes like the shell; and certainly for embedded and HPC it makes sense. I guess the moral, as always, is to measure.

Re:Sta.li: Static Linux by prewett on Wednesday February 19, 2014 @03:43AM (#7262560)
A lot of those pages will already be in the file cache (assuming his use case of small utilities running frequently). Anyway, it should be easy to test: since glibc will always be in memory, any differences in timing between the static and dynamic version should be those alleged loading costs.
Re:Sta.li: Static Linux by pjmlp on Wednesday February 19, 2014 @01:57AM (#7262250)
How many minutes are saved by 10-20% faster? A few seconds don't matter for a human.
Re:Sta.li: Static Linux by clord on Wednesday February 19, 2014 @10:08AM (#7263948)
We have some scripts at work that take 10+ hours to execute. Granted most of that time is in large child processes.