OLD | NEW |
(Empty) | |
| 1 A zygote process is one that listens for spawn requests from a master process an
d forks itself in response. Generally they are used because forking a process af
ter some expensive setup has been performed can save time and share extra memory
pages. |
| 2 |
| 3 On Linux, for Chromium, this is not the point, and measurements suggest that the
time and memory savings are minimal or negative. |
| 4 |
| 5 We use it because it's the only reasonable way to keep a reference to a binary a
nd a set of shared libraries that can be exec'ed. In the model used on Windows a
nd Mac, renderers are exec'ed as needed from the chrome binary. However, if the
chrome binary, or any of its shared libraries are updated while Chrome is runnin
g, we'll end up exec'ing the wrong version. A version _x_ browser might be talki
ng to a version _y_ renderer. Our IPC system does not support this (and does not
want to!). |
| 6 |
| 7 So we would like to keep a reference to a binary and its shared libraries and ex
ec from these. However, unless we are going to write our own <tt>ld.so</tt>, the
re's no way to do this. |
| 8 |
| 9 Instead, we exec the prototypical renderer at the beginning of the browser execu
tion. When we need more renderers, we signal this prototypical process (the zygo
te) to fork itself. The zygote is always the correct version and, by exec'ing on
e, we make sure the renderers have a different address space randomisation than
the browser. |
| 10 |
| 11 The zygote process is triggered by the <tt>--type=zygote</tt> command line flag,
which causes <tt>ZygoteMain</tt> (in <tt>chrome/browser/zygote_main_linux.cc</t
t>) to be run. The zygote is launched from <tt>chrome/browser/zygote_host_linux.
cc</tt>. |
| 12 |
| 13 Signaling the zygote for a new renderer happens in <tt>chrome/browser/child_proc
ess_launcher.cc</tt>. |
| 14 |
| 15 You can use the <tt>--zygote-cmd-prefix</tt> flag to debug the zygote process. I
f you use <tt>--renderer-cmd-prefix</tt> then the zygote will be bypassed and re
nderers will be exec'ed afresh every time. |
OLD | NEW |