Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/gpu/chrome_content_gpu_client.cc

Issue 2360143006: Stack sampling profiler: run the profiler in the GPU process on trunk builds (Closed)
Patch Set: address comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/gpu/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/gpu/chrome_content_gpu_client.h" 5 #include "chrome/gpu/chrome_content_gpu_client.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/common/stack_sampling_configuration.h"
14 #include "components/metrics/child_call_stack_profile_collector.h" 15 #include "components/metrics/child_call_stack_profile_collector.h"
15 #include "mojo/public/cpp/bindings/strong_binding.h" 16 #include "mojo/public/cpp/bindings/strong_binding.h"
16 #include "services/shell/public/cpp/connector.h" 17 #include "services/shell/public/cpp/connector.h"
17 #include "services/shell/public/cpp/interface_registry.h" 18 #include "services/shell/public/cpp/interface_registry.h"
18 19
19 #if defined(OS_CHROMEOS) 20 #if defined(OS_CHROMEOS)
20 #include "chrome/gpu/gpu_arc_video_service.h" 21 #include "chrome/gpu/gpu_arc_video_service.h"
21 #endif 22 #endif
22 23
23 namespace { 24 namespace {
24 25
25 #if defined(OS_CHROMEOS) 26 #if defined(OS_CHROMEOS)
26 void DeprecatedCreateGpuArcVideoService( 27 void DeprecatedCreateGpuArcVideoService(
27 const gpu::GpuPreferences& gpu_preferences, 28 const gpu::GpuPreferences& gpu_preferences,
28 ::arc::mojom::VideoAcceleratorServiceClientRequest client_request) { 29 ::arc::mojom::VideoAcceleratorServiceClientRequest client_request) {
29 chromeos::arc::GpuArcVideoService::DeprecatedConnect( 30 chromeos::arc::GpuArcVideoService::DeprecatedConnect(
30 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences), 31 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences),
31 std::move(client_request)); 32 std::move(client_request));
32 } 33 }
33 34
34 void CreateGpuArcVideoService( 35 void CreateGpuArcVideoService(
35 const gpu::GpuPreferences& gpu_preferences, 36 const gpu::GpuPreferences& gpu_preferences,
36 ::arc::mojom::VideoAcceleratorServiceRequest request) { 37 ::arc::mojom::VideoAcceleratorServiceRequest request) {
37 mojo::MakeStrongBinding( 38 mojo::MakeStrongBinding(
38 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences), 39 base::MakeUnique<chromeos::arc::GpuArcVideoService>(gpu_preferences),
39 std::move(request)); 40 std::move(request));
40 } 41 }
41 #endif 42 #endif
42 43
43 // Returns appropriate parameters for stack sampling on startup.
44 base::StackSamplingProfiler::SamplingParams GetStartupSamplingParams() {
45 base::StackSamplingProfiler::SamplingParams params;
46 params.initial_delay = base::TimeDelta::FromMilliseconds(0);
47 params.bursts = 1;
48 params.samples_per_burst = 300;
49 params.sampling_interval = base::TimeDelta::FromMilliseconds(100);
50 return params;
51 }
52
53 base::LazyInstance<metrics::ChildCallStackProfileCollector>::Leaky 44 base::LazyInstance<metrics::ChildCallStackProfileCollector>::Leaky
54 g_call_stack_profile_collector = LAZY_INSTANCE_INITIALIZER; 45 g_call_stack_profile_collector = LAZY_INSTANCE_INITIALIZER;
55 46
56 } // namespace 47 } // namespace
57 48
58 ChromeContentGpuClient::ChromeContentGpuClient() 49 ChromeContentGpuClient::ChromeContentGpuClient()
59 : stack_sampling_profiler_( 50 : stack_sampling_profiler_(
60 base::PlatformThread::CurrentId(), 51 base::PlatformThread::CurrentId(),
61 GetStartupSamplingParams(), 52 StackSamplingConfiguration::Get()->GetSamplingParamsForCurrentProcess(),
62 g_call_stack_profile_collector.Get().GetProfilerCallback( 53 g_call_stack_profile_collector.Get().GetProfilerCallback(
63 metrics::CallStackProfileParams( 54 metrics::CallStackProfileParams(
64 metrics::CallStackProfileParams::GPU_PROCESS, 55 metrics::CallStackProfileParams::GPU_PROCESS,
65 metrics::CallStackProfileParams::GPU_MAIN_THREAD, 56 metrics::CallStackProfileParams::GPU_MAIN_THREAD,
66 metrics::CallStackProfileParams::PROCESS_STARTUP, 57 metrics::CallStackProfileParams::PROCESS_STARTUP,
67 metrics::CallStackProfileParams::MAY_SHUFFLE))) { 58 metrics::CallStackProfileParams::MAY_SHUFFLE))) {
59 if (StackSamplingConfiguration::Get()->IsProfilerEnabledForCurrentProcess())
60 stack_sampling_profiler_.Start();
68 } 61 }
69 62
70 ChromeContentGpuClient::~ChromeContentGpuClient() {} 63 ChromeContentGpuClient::~ChromeContentGpuClient() {}
71 64
72 void ChromeContentGpuClient::Initialize( 65 void ChromeContentGpuClient::Initialize(
73 base::FieldTrialList::Observer* observer) { 66 base::FieldTrialList::Observer* observer) {
74 DCHECK(!field_trial_syncer_); 67 DCHECK(!field_trial_syncer_);
75 field_trial_syncer_.reset( 68 field_trial_syncer_.reset(
76 new chrome_variations::ChildProcessFieldTrialSyncer(observer)); 69 new chrome_variations::ChildProcessFieldTrialSyncer(observer));
77 const base::CommandLine& command_line = 70 const base::CommandLine& command_line =
(...skipping 12 matching lines...) Expand all
90 #endif 83 #endif
91 } 84 }
92 85
93 void ChromeContentGpuClient::ConsumeInterfacesFromBrowser( 86 void ChromeContentGpuClient::ConsumeInterfacesFromBrowser(
94 shell::InterfaceProvider* provider) { 87 shell::InterfaceProvider* provider) {
95 metrics::mojom::CallStackProfileCollectorPtr browser_interface; 88 metrics::mojom::CallStackProfileCollectorPtr browser_interface;
96 provider->GetInterface(&browser_interface); 89 provider->GetInterface(&browser_interface);
97 g_call_stack_profile_collector.Get().SetParentProfileCollector( 90 g_call_stack_profile_collector.Get().SetParentProfileCollector(
98 std::move(browser_interface)); 91 std::move(browser_interface));
99 } 92 }
OLDNEW
« no previous file with comments | « chrome/gpu/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698