by Already__Taken · 2y ago · 0 comments
In general, it's much easier to link a binary with its libraries than go in to the opposite direction (extracting common code from static linked binaries), because once you statically link a binary the library code will vary slightly due to differences in memory addresses, compiler optimizations, unused code that has been omitted, different input library versions, etc.
Even if you were, in theory, able to write a complex filesystem driver that is able to extract the common parts of statically linked libraries so they can be deduplicated, then to reconstruct the original binary in memory, you'd have to perform something similar to dynamic linking, except now in the kernel, which really isn't an improvement.
But aren't we, when we use OCI images as a packaging mechanism, using containers to essentially throw away that sharing and arrive at a complicated version of static linking, where everything dynamically linked is shipped with the program?
Same goes for arguments about ease of patching things. When the software's package is actually an image, you are patching each image individually that is running on the system.
For example, if you have a complex service that consists of multiple binaries all written in C++ using boost, then for each binary you can create a container that contains a layer of a base OS (shared), C++ libraries (shared), boost libraries (shared), application binary (unique).
All the services can now share their common libraries, both on disk and in memory, which reduces I/O and memory use. That's one of the main advantages of containers over virtual machines (VMs): each VM instance has a distinct region of memory that is not shared with others even if they happen to load bit-for-bit identical binaries into memory.
(I know, VM memory deduplication exists to ameliorate this problem, but here my previous comment applies: it's much easier to start from shared components and link them together than extract the shared data after the fact. And typically VMs have lots of nonsharable state that containers do share, like pretty much all writable kernel pages.)
Based on my understanding of cgroups, that seems unintuitive to me. Are you certain that's the case? I may try testing this out when I get a chance.
Wow, how is this possible using layers? How does docker handle it if I subsequently modify one of the files of my layer in my container?
So there's no free lunch and everything is a trade off. People thinking that containers are no more work than managing servers or services are in the wrong.
The problem is the way we usually package the apps with Docker-Dockerlike builders
And when your distro doesn't update? When the distro is slow to change?
Flatpak, Appimage, Snaps (why?)... upstream devs are bypassing distro maintainers in a lot of cases.
In your particular example, if you are not happy with your distro, you are free to find another one. Some distros are extremely fast to change.
> upstream devs are bypassing distro maintainers in a lot of cases
IMO, for open source projects, upstream devs should not distribute their library. They should let package maintainers do it for their distro.
Plus you don't need to recompile the universe because of a patch.
[1]: https://fuchsia.dev/fuchsia-src/concepts/filesystems/blobfs
Yes, some file systems implement "deduplication".
The strongest argument I can think of, is enabling system managers (distro maintainers, even end users) to update dependencies. This might be to apply a security patch, enable some kind of tracing for profiling an application, and so on.