News for hackers. Stuff that matters.
Re:The C standard library function atexit is broken by Annatar on Thursday June 20, 2019 @01:51AM (#20230267)
Shared object libraries are incredibly useful because they save memory and CPU resources. Cloning the process space during a fork(2) call, initializing structures, then context switching and whatnot is incredibly expensive.
Re:The C standard library function atexit is broken by _rtld_global_ro on Thursday June 20, 2019 @10:32AM (#20233278)
shared library can be expensive as well, the dynamic symbol lookup could be a lot more expensive than people would assume.
Re:The C standard library function atexit is broken by notacoward on Thursday June 20, 2019 @08:07PM (#20238721)
Correct. Shared libraries trade away CPU for memory. Even with some benefits in terms of cache warmth, the extra indirection and loader/VM complexity make shared libraries a net loss in terms of CPU.
Re:The C standard library function atexit is broken by coldtea on Thursday June 20, 2019 @04:05AM (#20230856)
>Cloning the process space during a fork(2) call, initializing structures, then context switching and whatnot is incredibly expensive.

Err, we're running Electron apps today, with a full blown embedded browser engine, a vm, and a hellish complex DOM for rendering. Others run apps inside containers, with their own basic OS and standard libs -- compared to that the above is negligible.

Re:The C standard library function atexit is broken by saagarjha on Thursday June 20, 2019 @04:47AM (#20231037)
> we're running Electron apps today

Some of us try not to on the belief that they don't perform acceptably.

Re:The C standard library function atexit is broken by imtringued on Thursday June 20, 2019 @07:42AM (#20231821)
You can usually avoid this problem by using the web version of Slack, Discord, Rocketchat, etc. A single browser running everything is obviously more efficient than running ten.
Re:The C standard library function atexit is broken by bayareanative on Thursday June 20, 2019 @06:12AM (#20231374)
Nope. A strawman wrong doesn't justify anything related to the topic. fork() duplicates everything, which maybe overkill, which is why pthreads and vfork+exec also exist.
Re:The C standard library function atexit is broken by notacoward on Thursday June 20, 2019 @08:04PM (#20238708)
That's not why pthreads exist, and vfork barely does. Pthreads exist to facilitate parallel operation (hence the name) on shared data, not as an efficiency measure. As for vfork, it has been deprecated since every UNIX implementation started marking pages as copy-on-write instead of actually copying. I was doing some of that work myself in 1990-91, so it's hardly new.

The real problems with static linking don't have to do with fork, except in the sense of increasing reliance on VM overcommit (which IMO is a bad idea already). It's more to do with masking reuse of the same library across unrelated processes, as an efficiency issue but even more importantly in terms of tracking dependencies and updating software. No matter how good your configuration management (or similar mechanism) is, rebuilding large-N statically linked executables is less efficient and more error-prone than using the same information to update small-N shared libraries.