Hacker News new | ask | show | jobs
by ktpsns 2628 days ago
Can anybody elucidate about why fork() is still used in Chromium or Node.js? They are not old-grown traditional forking Unix servers (unlike Apache or the mentioned databases in the paper). I would expect them to implement some of the alternatives and having fork() only as a fallback in the code (i.e. after a cascade of #ifdefs) if no other API is available. Therefore, I wonder where the fork() bottlenecks really appear in everyday's life.
3 comments

Chrome on Windows uses CreateProcess, and Windows came first, so Chrome is mostly architected around an approach that would fit posix_spawn better. However, fork has some benefits that I went into here:

http://neugierig.org/software/chromium/notes/2011/08/zygote....

> why fork() is still used in Chromium

To support a multi-process web browser architecture that Chromium pioneered, you need to spawn processes. See https://chromium.googlesource.com/chromium/src/+/HEAD/docs/l...

That's not what the page says. It says the use of fork() saves 8MB and a few tens of milliseconds per process spawn.
This is explained in the paper. It's to get access to copy-on-write memory so you can make a pre-initialised process cheaply.