Commit 381d19a1 authored by Patrick Monette's avatar Patrick Monette Committed by Commit Bot

Fix a startup performance issue with the ModuleDatabase feature

The ModuleEventSink interface was bound on the UI thread, which caused
cross-process IPC to retrieve information about a loaded module in the
renderer process.

A new sequence with background priority is instead used so that it
doesn't impact startup.

Bug: 832286
Change-Id: I5ab50bc45386c9a1ddb2888f80293d78bd768a88
Reviewed-on: https://chromium-review.googlesource.com/1037935Reviewed-by: default avatarChris Hamilton <chrisha@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Patrick Monette <pmonette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558010}
parent 770b4370
......@@ -345,7 +345,7 @@ void OnModuleEvent(const ModuleWatcher::ModuleEvent& event) {
// task.
base::PostTaskWithTraits(
FROM_HERE,
{base::MayBlock(),
{base::MayBlock(), base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
base::Bind(&HandleModuleLoadEventWithoutTimeDateStamp,
event.module_path, event.module_size, load_address));
......
......@@ -28,6 +28,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/sys_info.h"
#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "chrome/browser/after_startup_task_utils.h"
......@@ -3276,9 +3277,8 @@ void ChromeContentBrowserClient::ExposeInterfacesToRenderer(
// process handle is not yet available at this point so pass in a callback
// to allow it to be retrieved at the time the interface is actually
// created. It is safe to pass a raw pointer to |render_process_host|: the
// callback will be invoked in the context of ModuleDatabase::GetInstance,
// which is invoked by Mojo initialization, which occurs while the
// |render_process_host| is alive.
// callback will be invoked in the context of Mojo initialization, which
// occurs while the |render_process_host| is alive.
auto get_process = base::BindRepeating(
[](content::RenderProcessHost* host) -> base::ProcessHandle {
return host->GetProcess().Handle();
......@@ -3291,7 +3291,9 @@ void ChromeContentBrowserClient::ExposeInterfacesToRenderer(
std::move(get_process),
content::PROCESS_TYPE_RENDERER,
base::Unretained(ModuleDatabase::GetInstance())),
ui_task_runner);
base::CreateSequencedTaskRunnerWithTraits(
{base::TaskPriority::BACKGROUND,
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}));
}
#endif
......
......@@ -8,6 +8,7 @@
#include <psapi.h>
#include <memory>
#include <utility>
#include <vector>
......@@ -111,7 +112,6 @@ void ModuleEventSinkImpl::Create(
content::ProcessType process_type,
ModuleDatabase* module_database,
mojom::ModuleEventSinkRequest request) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::ProcessHandle process = get_process_handle.Run();
auto module_event_sink_impl = std::make_unique<ModuleEventSinkImpl>(
process, process_type, module_database);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment