4 ms·
Shared libraries can reduce load time as they might already be in page cache. There’s also potential for a small impact in reduced instruction cache misses. O
by jnwatson 4y ago
Shared libraries can reduce load time as they might already be in page cache. There’s also potential for a small impact in reduced instruction cache misses.
On the other side, link time optimization on static libraries allows deletion of unused functions and more aggressive inlining, so you might get that performance back and more.
- dralley 4y agoPeople say this but every test case I've seen has proven otherwise. Static binaries load much faster. Maybe it depends on the size of the libraries involved an the quality of the OS' dynamic linking machinery (supposedly OSX has better runtime dynamic linking startup times than linux), but at the very least it is conditional, not a pure win.
- CamperBob2 4y agoNot only that, but executable images are demand-paged anyway. You can link 1 GB of static library code if you like; you won't pay the penalty unless and until those functions are actually called. The whole debate is just stupid. If it inconveniences even one fewer user, then static linking is the way to go, because of the sheer number of drawbacks that shared libraries bring. Nobody cares how big the executable is. If you do, well... the best time to stop caring was 10 years ago, and the second best time is now.
- bombolo 4y agoBut the called functions need to be loaded in memory for every process using them, instead of once. Also there is value in being able to fix a library without having to recompile everything.
- deleted 4y ago[deleted]
- craftkiller 4y agoEverything is getting recompiled all the time anyway. At least with FreeBSD, any time a dependency is updated, all the packages that depend on that package get rebuilt. There's no concept of "this was a small update and its dynamically linked", its just "the version string changed, so rebuild everything that lists it as a dependency". This is particularly "fun" for web browsers because they have a lot of dependencies, ensuring they're rebuilt often, and they take a long time to build.
- bombolo 4y ago> Everything is getting recompiled all the time anyway. Source? I know when stuff on my distribution gets recompiled because then I have to download and unpack it, so I notice. I can assure you that it isn't as you say. > with FreeBSD Despite the monorepo thing, I assure you that most FreeBSD users do use software coming from other places as well.
- CamperBob2 4y agoIf nothing else, you probably see several megabytes' worth of JIT compilation whenever you visit a JavaScript-heavy web page. Same effect... namely, none at all.
- bombolo 4y agoLol sure… JIT only does the hot paths, not the whole thing. It certainly will not make several mb of output without my computer sounding like an ariane5 launch
- CamperBob2 4y agoAlso there is value in being able to fix a library without having to recompile everything. Number of times I have benefited from this process: 0 (AFAIK) Number of times this process has hosed previously-working applications and components: too many to count On Windows, this "feature" was called "DLL Hell," and was generally considered a bad thing. Nothing has fundamentally changed since it was a common practice for every installer to have its way with c:\windows, IMHO. (Admittedly shared MSVC runtimes aren't as big a problem as the Winsock-provider-du-jour was, but still... there is simply no point.)
- bombolo 4y ago> Number of times I have benefited from this process: 0 (AFAIK) Every day on my distribution, when I have to download 5kb of library instead of 3GB of everything recompiled…