Commit bd6bbb6e authored by Sadrul Habib Chowdhury's avatar Sadrul Habib Chowdhury Committed by Commit Bot

Reland "metrics: Initialize persistent metric allocator early."

The fix from the original change is to share the shared-memory handle
with the child process only if a child process is actually launched.
There can be configurations where a child-process is not launched (e.g.
for in-process gpu etc.), and in such cases, it is not necessary to
create a separate PersistentMemoryAllocator, since there already is an
existing one for the browser process.

Original change's description:
metrics: Initialize persistent metric allocator early.

The PersistentMemoryAllocator in the gpu (and other) process is created
asynchronously. If any uma-histogram is reported before that time, then
those Histograms are not stored in the shared memory. This has some
implications:
 . If the process crashes (which is common for the gpu process on
   android), then these metrics are lost.
 . If the process stays alive, then the metrics are reported
   periodically, but because it is buffered, it doesn't match up
   correctly with the other metrics that are reported in the shared
   memory.

The allocator is created in response to a message from the browser,
which includes the handle for the shared memory to use for the allocator.
The browser waits until the process has been launched and connected.
So this happens much later, compared to other messages which are sent
from browser over mojo without waiting for the connection to have
been established first. Therefore, change this so that the browser
immediately shares the shared-memory segment with the gpu process. mojo
takes care of waiting for the process-launch etc.

BUG=865179, 778749, 875640

Change-Id: Ieffc014ae711d4bc922cda8034bc4a05fd861bde
Reviewed-on: https://chromium-review.googlesource.com/1182041Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584642}
parent d713e0c0
......@@ -277,6 +277,7 @@ void BrowserChildProcessHostImpl::Launch(
weak_factory_.GetWeakPtr(),
base::ThreadTaskRunnerHandle::Get()),
terminate_on_shutdown));
ShareMetricsAllocatorToProcess();
}
const ChildProcessData& BrowserChildProcessHostImpl::GetData() const {
......@@ -389,7 +390,6 @@ void BrowserChildProcessHostImpl::OnChannelConnected(int32_t peer_pid) {
delegate_->OnChannelConnected(peer_pid);
if (IsProcessLaunched()) {
ShareMetricsAllocatorToProcess();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&NotifyProcessLaunchedAndConnected, data_.Duplicate()));
......@@ -608,7 +608,6 @@ void BrowserChildProcessHostImpl::OnProcessLaunched() {
delegate_->OnProcessLaunched();
if (is_channel_connected_) {
ShareMetricsAllocatorToProcess();
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::BindOnce(&NotifyProcessLaunchedAndConnected, data_.Duplicate()));
......
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