Hacker News new | past | comments | ask | show | jobs | submit login

Yep. There's a reason why macOS and iOS have a giant (easily 1GB) "shared cache" that is most of the libraries that make up the OS in a giant file, mapped into every process's address space.

Without shared linking, in your example you end up with a copy of glibc and whatever else in every process. Without some fancy page deduplication scheme (that would come with its own set of problems), the kernel cannot know that all these pages in all these processes are the same. And they might not even be, because different versions and just the process of static linking itself might make an arbitrary number of them look slightly different.

Not every program needs all of glibc, so not all of it will be paged in, but still, it looks like you will pollute your CPU caches with many copies of essentially the same thing.




I'd love to see some instrumentation demonstrating this. I've never been able to find any evidence whatsoever that it's the case. It makes sense intuitively but I yearn for proof.


Yeah, totally fair. I mean it's relatively hard for me to conclude otherwise, but stuff is super complex, you never know. If not anything else, after all you can do link time optimization on the actual whole program, including its libraries. But whether that offsets it...

I thought about whether there was some quick evidence already, but nothing comes to mind (maybe someone's less blind to it than me now).

Maybe you could take some self-building Linux distribution like Gentoo, and hack it such that it links everything statically? Compare that against an equivalent unhacked Gentoo-installation by doing a few tasks, measuring wall clock for a good first estimate?

No idea how hard that would be in practice, especially with people mentioning that glibc does not really support that. So maybe it's actually easier with one of the BSDs, e.g. OpenBSD, which is also feasible to build completely from source because it is very self-contained, depending on how that stomachs static linking for everything.

I'd also not do it in a VM. While that's not necessarily completely invalid, it does seem to skew things pretty significantly, what with at least one whole other OS running as the hypervisor and all that.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: