posix_spawn() is a replacement for fork+exec that can be much faster. Here's a benchmark on Linux and Mac:
https://github.com/rtomayko/posix-spawn#benchmarks
fork()ing from the browser process is slow because all pages need to be marked copy-on-write. Then when exec() runs, all of those pages are set back to read+write (or readonly or whatever it was before). For large processes like Chrome, this can be very expensive. The benchmark above suggests there's a 0.07s overhead on Linux when fork/exec is run from a 500MB process.
posix_spawn() creates a brand new process and runs in constant time. The benchmark indicates it's ~35x faster for 500MB processes on Linux.
We have a seemingly harmless fork+exec on every browser start here:
https://cs.chromium.org/chromium/src/chrome/browser/shell_integration_linux.cc?rcl=84c251d6b35a0e4c0d5cbb7ec84f58ac2a52098f&l=191
which runs "xdg-settings check default-web-browser google-chrome.desktop". We could get a speedup in browser start time by using posix_spawn() here instead.
I suggest we use posix_spawn() when available for base::GetAppOutputInternal().
Also relevant is bug 22703.
+thestig does this sound reasonable?
Comment 1 by thestig@chromium.org
, Aug 1