Commit 3c3b4bf7 authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Ensure that child processes dump their profiling data when terminating

This ensures that child processes don't die before flushing their
profile data to disk. This is supposed to happen automatically at
shutdown but it doesn't always have a chance to complete (probably
because we tend to fast kill processes). This affects mostly the utility
processes, and as they end up writing their data into the same file as
the renderer they can sometime end up corrupting these files and make us
lose some precious profiling data.

This only affects profile instrumented builds (PGO profiling builds and
coverage builds).


Bug: 1119887
Change-Id: Ib50e876e7637a670ad05982c5ff03a898dc84ff5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2378272Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarYuke Liao <liaoyuke@chromium.org>
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802348}
parent 2bdb3fe4
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <string.h> #include <string.h>
#include "base/bind.h" #include "base/bind.h"
#include "base/clang_profiling_buildflags.h"
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/message_loop/message_pump_type.h" #include "base/message_loop/message_pump_type.h"
#include "base/process/process_handle.h" #include "base/process/process_handle.h"
...@@ -23,6 +24,10 @@ ...@@ -23,6 +24,10 @@
#include "services/tracing/public/cpp/trace_startup.h" #include "services/tracing/public/cpp/trace_startup.h"
#include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/features.h"
#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX)
#include "base/test/clang_profiling.h"
#endif
namespace content { namespace content {
namespace { namespace {
...@@ -121,6 +126,13 @@ ChildProcess::~ChildProcess() { ...@@ -121,6 +126,13 @@ ChildProcess::~ChildProcess() {
DCHECK(base::ThreadPoolInstance::Get()); DCHECK(base::ThreadPoolInstance::Get());
base::ThreadPoolInstance::Get()->Shutdown(); base::ThreadPoolInstance::Get()->Shutdown();
} }
#if BUILDFLAG(CLANG_PROFILING_INSIDE_SANDBOX)
// Flush the profiling data to disk. Doing this manually (vs relying on this
// being done automatically when the process exits) will ensure that this data
// doesn't get lost if the process is fast killed.
base::WriteClangProfilingProfile();
#endif
} }
ChildThreadImpl* ChildProcess::main_thread() { ChildThreadImpl* ChildProcess::main_thread() {
......
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