diff options
author | kerrnel <kerrnel@chromium.org> | 2016-02-01 10:57:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-01 18:58:21 +0000 |
commit | 94807ee60fa56c118cac88b0f8f4e4e5231ef43f (patch) | |
tree | b878480cc1ac0d59d24f344d19f6a417e4202074 | |
parent | 2a3587907d9d5b3aa0bb1931e2577dcf7e48ec60 (diff) | |
download | chromium_src-94807ee60fa56c118cac88b0f8f4e4e5231ef43f.zip chromium_src-94807ee60fa56c118cac88b0f8f4e4e5231ef43f.tar.gz chromium_src-94807ee60fa56c118cac88b0f8f4e4e5231ef43f.tar.bz2 |
Use a single, generic, global zygote to temporarily resolve perf regressions.
The CL to have multiple zygotes has caused some performance regressions,
due to the additional startup time required to launch the processes. This CL
keeps then new API in place, but uses a single global zygote, resolving the
startup overhead. Once the performance of permanent solutions has been measured
and thought through, Chrome will return to having multiple zygote processes.
BUG=569191,580966,580974
Review URL: https://codereview.chromium.org/1643533006
Cr-Commit-Position: refs/heads/master@{#372709}
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 5 | ||||
-rw-r--r-- | components/nacl/browser/nacl_process_host.cc | 4 | ||||
-rw-r--r-- | content/browser/browser_main_loop.cc | 10 | ||||
-rw-r--r-- | content/browser/ppapi_plugin_process_host.cc | 2 | ||||
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 5 | ||||
-rw-r--r-- | content/browser/utility_process_host_impl.cc | 2 | ||||
-rw-r--r-- | content/browser/zygote_host/zygote_handle_linux.cc | 5 | ||||
-rw-r--r-- | content/public/browser/zygote_handle_linux.h | 7 |
8 files changed, 22 insertions, 18 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 36780c6..75aefe8 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -1626,11 +1626,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { BrowserThread::IO, FROM_HERE, base::Bind(nacl::NaClProcessHost::EarlyStartup)); - -#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) - BrowserThread::PostTask(BrowserThread::PROCESS_LAUNCHER, FROM_HERE, - base::Bind(nacl::NaClProcessHost::EarlyZygoteLaunch)); -#endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) #endif // !defined(DISABLE_NACL) // Make sure initial prefs are recorded diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc index 3b57e14..01fed51 100644 --- a/components/nacl/browser/nacl_process_host.cc +++ b/components/nacl/browser/nacl_process_host.cc @@ -186,7 +186,9 @@ class NaClSandboxedProcessLauncherDelegate } #elif defined(OS_POSIX) #if !defined(OS_MACOSX) - content::ZygoteHandle* GetZygote() override { return &g_nacl_zygote; } + content::ZygoteHandle* GetZygote() override { + return content::GetGenericZygote(); + } #endif // !defined(OS_MACOSX) base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index 012926b..198ef85 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -156,9 +156,10 @@ #include "sandbox/linux/suid/client/setuid_sandbox_host.h" #if !defined(OS_ANDROID) -#include "content/browser/ppapi_plugin_process_host.h" -#endif -#endif +#include "content/public/browser/zygote_handle_linux.h" +#endif // !defined(OS_ANDROID) +#endif // defined(OS_POSIX) && !defined(OS_MACOSX) + #if defined(ENABLE_PLUGINS) #include "content/browser/plugin_service_impl.h" @@ -222,9 +223,8 @@ void SetupSandbox(const base::CommandLine& parsed_command_line) { // Tickle the sandbox host and zygote host so they fork now. RenderSandboxHostLinux::GetInstance()->Init(); ZygoteHostImpl::GetInstance()->Init(sandbox_binary.value()); + *GetGenericZygote() = CreateZygote(); RenderProcessHostImpl::EarlyZygoteLaunch(); - PpapiPluginProcessHost::EarlyZygoteLaunch(); - UtilityProcessHostImpl::EarlyZygoteLaunch(); } #endif diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc index 4ff33a6..139cdea 100644 --- a/content/browser/ppapi_plugin_process_host.cc +++ b/content/browser/ppapi_plugin_process_host.cc @@ -121,7 +121,7 @@ class PpapiPluginSandboxedProcessLauncherDelegate .GetSwitchValueNative(switches::kPpapiPluginLauncher); if (is_broker_ || !plugin_launcher.empty()) return nullptr; - return &g_ppapi_zygote; + return GetGenericZygote(); } #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index fccb73f..160ef01 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -409,7 +409,7 @@ class RendererSandboxedProcessLauncherDelegate browser_command_line.GetSwitchValueNative(switches::kRendererCmdPrefix); if (!renderer_prefix.empty()) return nullptr; - return &g_render_zygote; + return GetGenericZygote(); } #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } @@ -545,12 +545,11 @@ void RenderProcessHost::SetMaxRendererProcessCount(size_t count) { // static void RenderProcessHostImpl::EarlyZygoteLaunch() { DCHECK(!g_render_zygote); - g_render_zygote = CreateZygote(); // TODO(kerrnel): Investigate doing this without the ZygoteHostImpl as a // proxy. It is currently done this way due to concerns about race // conditions. ZygoteHostImpl::GetInstance()->SetRendererSandboxStatus( - g_render_zygote->GetSandboxStatus()); + (*GetGenericZygote())->GetSandboxStatus()); } #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc index 447685a..f51ec29 100644 --- a/content/browser/utility_process_host_impl.cc +++ b/content/browser/utility_process_host_impl.cc @@ -104,7 +104,7 @@ class UtilitySandboxedProcessLauncherDelegate ZygoteHandle* GetZygote() override { if (no_sandbox_ || !exposed_dir_.empty()) return nullptr; - return &g_utility_zygote; + return GetGenericZygote(); } #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) base::EnvironmentMap GetEnvironment() override { return env_; } diff --git a/content/browser/zygote_host/zygote_handle_linux.cc b/content/browser/zygote_host/zygote_handle_linux.cc index 89adc49..55830f5 100644 --- a/content/browser/zygote_host/zygote_handle_linux.cc +++ b/content/browser/zygote_host/zygote_handle_linux.cc @@ -14,4 +14,9 @@ ZygoteHandle CreateZygote() { return zygote; } +ZygoteHandle* GetGenericZygote() { + static ZygoteHandle zygote; + return &zygote; +} + } // namespace content diff --git a/content/public/browser/zygote_handle_linux.h b/content/public/browser/zygote_handle_linux.h index b644c51..6419b74 100644 --- a/content/public/browser/zygote_handle_linux.h +++ b/content/public/browser/zygote_handle_linux.h @@ -5,8 +5,6 @@ #ifndef CONTENT_PUBLIC_BROWSER_ZYGOTE_HANDLE_LINUX_H_ #define CONTENT_PUBLIC_BROWSER_ZYGOTE_HANDLE_LINUX_H_ -#include <cstddef> - #include "content/common/content_export.h" #include "content/public/common/zygote_handle.h" @@ -16,6 +14,11 @@ namespace content { // ZygoteHandle used to communicate with it. CONTENT_EXPORT ZygoteHandle CreateZygote(); +// Returns a handle to a global generic zygote object. This function allows the +// browser to launch and use a single zygote process until the performance +// issues around launching multiple zygotes are resolved. +CONTENT_EXPORT ZygoteHandle* GetGenericZygote(); + } // namespace content #endif // CONTENT_PUBLIC_BROWSER_ZYGOTE_HANDLE_LINUX_H_ |