0
Files
src/content/utility
Lingqi Chi f7ef80f606 Sampling profiler: profile the NetworkService process
In the out-of-process case, network service runs on the IO thread of a
utility process handling network-related tasks. See
services/network/README.md for more details.
To track the utility network service process, this CL enables sampling
profiler in this process. It updates the StackSamplingConfiguration to
turn on the switch of profiler in the network service process. Then when
the switch is on, ChromeContentUtilityClient will create and start a
profiler for the IO thread, and build a message pipe between the utility
network service process and the browser process to pass the collected
profile data.
If the switch is on, the procedure will be:
1. In the |UtilityMain| function, which is the mainline routine of a
utility process, a |ChildProcess| is created. This instance contains the
delegate of the IO thread and its task runner. Then
|ChromeContentUtilityClient::PostIOThreadCreated| will create
and start a profiler for the IO thread.
2. A |UtilityThreadImpl| instance is created in the |UtilityMain| as
well, it will be the main thread of the process. To initialize the
instance, |UtilityThreadImpl::Init| function is called. This function
only runs once in every utility process so, in this function,
|ChromeContentUtilityClient::UtilityThreadStarted| will create a message
pipe between the utility network service process and the browser process
to pass the collected profile data.
Note that there are some in-process utility threads run in other
processes, so please check the process type before setting up the
collector and pipe.
3. More specifically, it will create a |PendingReceiver| of
|CallStackProfileCollector|. And the browser process will receive and
handle this receiver. The path is:
  |ChildThread::BindHostReceiver| =>
  |UtilityProcessHost::BindHostReceiver| =>
  |ChromeContentBrowserClient::BindUtilityHostReceiver|.
In the utility process side, |SetCollectorForChildProcess| is called to
supply the Service Manager's connector; and in the browser process side,
a |CallStackProfileCollector| will be created with the receiver.

Bug: 931432
Change-Id: I245f864089d82aee09c30a42c1606a93cf5ea1c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2186614
Commit-Queue: Lingqi Chi <lingqi@google.com>
Reviewed-by: Matt Falkenhagen <falken@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Mike Wittman <wittman@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777632}
2020-06-12 02:04:46 +00:00
..