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

Side by Side Diff: content/browser/tracing/background_tracing_manager_impl.cc

Issue 2034553002: Set up background memory light tracing field trials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@set_whitelist
Patch Set: Remove navigation_tracing change and add base_export. Created 4 years, 6 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 | « content/browser/tracing/background_tracing_manager_impl.h ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/tracing/background_tracing_manager_impl.h" 5 #include "content/browser/tracing/background_tracing_manager_impl.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/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 28 matching lines...) Expand all
39 FINALIZATION_COMPLETE = 8, 39 FINALIZATION_COMPLETE = 8,
40 SCENARIO_ACTION_FAILED_LOWRES_CLOCK = 9, 40 SCENARIO_ACTION_FAILED_LOWRES_CLOCK = 9,
41 NUMBER_OF_BACKGROUND_TRACING_METRICS, 41 NUMBER_OF_BACKGROUND_TRACING_METRICS,
42 }; 42 };
43 43
44 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) { 44 void RecordBackgroundTracingMetric(BackgroundTracingMetrics metric) {
45 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric, 45 UMA_HISTOGRAM_ENUMERATION("Tracing.Background.ScenarioState", metric,
46 NUMBER_OF_BACKGROUND_TRACING_METRICS); 46 NUMBER_OF_BACKGROUND_TRACING_METRICS);
47 } 47 }
48 48
49 // Tracing enabled callback for BENCHMARK_MEMORY_LIGHT category preset.
50 // TODO(ssid): Remove this when background tracing supports trace config strings
51 // and memory-infra supports peak detection crbug.com/609935.
52 void BenchmarkMemoryLight_TracingEnabledCallback() {
53 base::trace_event::MemoryDumpManager::GetInstance()->RequestGlobalDump(
54 base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED,
55 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND);
56 }
57
49 } // namespace 58 } // namespace
50 59
51 BackgroundTracingManagerImpl::TracingTimer::TracingTimer( 60 BackgroundTracingManagerImpl::TracingTimer::TracingTimer(
52 StartedFinalizingCallback callback) : callback_(callback) { 61 StartedFinalizingCallback callback) : callback_(callback) {
53 } 62 }
54 63
55 BackgroundTracingManagerImpl::TracingTimer::~TracingTimer() { 64 BackgroundTracingManagerImpl::TracingTimer::~TracingTimer() {
56 } 65 }
57 66
58 void BackgroundTracingManagerImpl::TracingTimer::StartTimer(int seconds) { 67 void BackgroundTracingManagerImpl::TracingTimer::StartTimer(int seconds) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 *config_.get(), requires_anonymized_data_)) { 212 *config_.get(), requires_anonymized_data_)) {
204 AbortScenario(); 213 AbortScenario();
205 } 214 }
206 } 215 }
207 216
208 void BackgroundTracingManagerImpl::StartTracingIfConfigNeedsIt() { 217 void BackgroundTracingManagerImpl::StartTracingIfConfigNeedsIt() {
209 if (!config_) 218 if (!config_)
210 return; 219 return;
211 220
212 if (config_->tracing_mode() == BackgroundTracingConfigImpl::PREEMPTIVE) { 221 if (config_->tracing_mode() == BackgroundTracingConfigImpl::PREEMPTIVE) {
213 StartTracing( 222 StartTracing(config_->category_preset(),
214 GetCategoryFilterStringForCategoryPreset(config_->category_preset()), 223 base::trace_event::RECORD_CONTINUOUSLY);
215 base::trace_event::RECORD_CONTINUOUSLY);
216 } 224 }
217 // There is nothing to do in case of reactive tracing. 225 // There is nothing to do in case of reactive tracing.
218 } 226 }
219 227
220 BackgroundTracingRule* 228 BackgroundTracingRule*
221 BackgroundTracingManagerImpl::GetRuleAbleToTriggerTracing( 229 BackgroundTracingManagerImpl::GetRuleAbleToTriggerTracing(
222 TriggerHandle handle) const { 230 TriggerHandle handle) const {
223 if (!config_) 231 if (!config_)
224 return nullptr; 232 return nullptr;
225 233
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 314
307 int trace_delay = triggered_rule->GetTraceDelay(); 315 int trace_delay = triggered_rule->GetTraceDelay();
308 316
309 if (config_->tracing_mode() == BackgroundTracingConfigImpl::REACTIVE) { 317 if (config_->tracing_mode() == BackgroundTracingConfigImpl::REACTIVE) {
310 // In reactive mode, a trigger starts tracing, or finalizes tracing 318 // In reactive mode, a trigger starts tracing, or finalizes tracing
311 // immediately if it's already running. 319 // immediately if it's already running.
312 RecordBackgroundTracingMetric(REACTIVE_TRIGGERED); 320 RecordBackgroundTracingMetric(REACTIVE_TRIGGERED);
313 321
314 if (!is_tracing_) { 322 if (!is_tracing_) {
315 // It was not already tracing, start a new trace. 323 // It was not already tracing, start a new trace.
316 StartTracing(GetCategoryFilterStringForCategoryPreset( 324 StartTracing(triggered_rule->category_preset(),
317 triggered_rule->category_preset()),
318 base::trace_event::RECORD_UNTIL_FULL); 325 base::trace_event::RECORD_UNTIL_FULL);
319 } else { 326 } else {
320 // Reactive configs that trigger again while tracing should just 327 // Reactive configs that trigger again while tracing should just
321 // end right away (to not capture multiple navigations, for example). 328 // end right away (to not capture multiple navigations, for example).
322 trace_delay = -1; 329 trace_delay = -1;
323 } 330 }
324 } else { 331 } else {
325 // In preemptive mode, a trigger starts finalizing a trace if one is 332 // In preemptive mode, a trigger starts finalizing a trace if one is
326 // running and we're not got a finalization timer running, 333 // running and we're not got a finalization timer running,
327 // otherwise we do nothing. 334 // otherwise we do nothing.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 const base::Closure& callback) { 388 const base::Closure& callback) {
382 rule_triggered_callback_for_testing_ = callback; 389 rule_triggered_callback_for_testing_ = callback;
383 }; 390 };
384 391
385 void BackgroundTracingManagerImpl::FireTimerForTesting() { 392 void BackgroundTracingManagerImpl::FireTimerForTesting() {
386 DCHECK(tracing_timer_); 393 DCHECK(tracing_timer_);
387 tracing_timer_->FireTimerForTesting(); 394 tracing_timer_->FireTimerForTesting();
388 } 395 }
389 396
390 void BackgroundTracingManagerImpl::StartTracing( 397 void BackgroundTracingManagerImpl::StartTracing(
391 std::string category_filter_str, 398 BackgroundTracingConfigImpl::CategoryPreset preset,
392 base::trace_event::TraceRecordMode record_mode) { 399 base::trace_event::TraceRecordMode record_mode) {
393 base::trace_event::TraceConfig trace_config(category_filter_str, record_mode); 400 base::trace_event::TraceConfig trace_config(
401 GetCategoryFilterStringForCategoryPreset(preset), record_mode);
394 if (requires_anonymized_data_) 402 if (requires_anonymized_data_)
395 trace_config.EnableArgumentFilter(); 403 trace_config.EnableArgumentFilter();
396 404
405 base::Closure tracing_enabled_callback;
406 if (!tracing_enabled_callback_for_testing_.is_null()) {
407 tracing_enabled_callback = tracing_enabled_callback_for_testing_;
408 } else if (preset == BackgroundTracingConfigImpl::CategoryPreset::
409 BENCHMARK_MEMORY_LIGHT) {
410 // On memory light mode, the periodic memory dumps are disabled and a single
411 // memory dump is requested after tracing is enabled in all the processes.
412 trace_config.ResetMemoryDumpConfig(
413 base::trace_event::TraceConfig::MemoryDumpConfig());
414 tracing_enabled_callback =
415 base::Bind(&BenchmarkMemoryLight_TracingEnabledCallback);
416 }
417
397 is_tracing_ = TracingController::GetInstance()->StartTracing( 418 is_tracing_ = TracingController::GetInstance()->StartTracing(
398 trace_config, tracing_enabled_callback_for_testing_); 419 trace_config, tracing_enabled_callback);
399 RecordBackgroundTracingMetric(RECORDING_ENABLED); 420 RecordBackgroundTracingMetric(RECORDING_ENABLED);
400 } 421 }
401 422
402 void BackgroundTracingManagerImpl::OnFinalizeStarted( 423 void BackgroundTracingManagerImpl::OnFinalizeStarted(
403 std::unique_ptr<const base::DictionaryValue> metadata, 424 std::unique_ptr<const base::DictionaryValue> metadata,
404 base::RefCountedString* file_contents) { 425 base::RefCountedString* file_contents) {
405 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 426 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
406 427
407 RecordBackgroundTracingMetric(FINALIZATION_STARTED); 428 RecordBackgroundTracingMetric(FINALIZATION_STARTED);
408 UMA_HISTOGRAM_MEMORY_KB("Tracing.Background.FinalizingTraceSizeInKB", 429 UMA_HISTOGRAM_MEMORY_KB("Tracing.Background.FinalizingTraceSizeInKB",
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 return "benchmark,toplevel,gpu"; 533 return "benchmark,toplevel,gpu";
513 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_IPC: 534 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_IPC:
514 return "benchmark,toplevel,ipc"; 535 return "benchmark,toplevel,ipc";
515 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_STARTUP: 536 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_STARTUP:
516 return "benchmark,toplevel,startup,disabled-by-default-file," 537 return "benchmark,toplevel,startup,disabled-by-default-file,"
517 "disabled-by-default-toplevel.flow," 538 "disabled-by-default-toplevel.flow,"
518 "disabled-by-default-ipc.flow"; 539 "disabled-by-default-ipc.flow";
519 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_BLINK_GC: 540 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_BLINK_GC:
520 return "blink_gc,disabled-by-default-blink_gc"; 541 return "blink_gc,disabled-by-default-blink_gc";
521 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_MEMORY_HEAVY: 542 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_MEMORY_HEAVY:
543 case BackgroundTracingConfigImpl::CategoryPreset::BENCHMARK_MEMORY_LIGHT:
522 return "-*,disabled-by-default-memory-infra"; 544 return "-*,disabled-by-default-memory-infra";
523 case BackgroundTracingConfigImpl::CategoryPreset:: 545 case BackgroundTracingConfigImpl::CategoryPreset::
524 BENCHMARK_EXECUTION_METRIC: 546 BENCHMARK_EXECUTION_METRIC:
525 return "blink.console,v8"; 547 return "blink.console,v8";
526 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE: 548 case BackgroundTracingConfigImpl::CategoryPreset::BLINK_STYLE:
527 return "blink_style"; 549 return "blink_style";
528 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET: 550 case BackgroundTracingConfigImpl::CategoryPreset::CATEGORY_PRESET_UNSET:
529 NOTREACHED(); 551 NOTREACHED();
530 } 552 }
531 NOTREACHED(); 553 NOTREACHED();
532 return ""; 554 return "";
533 } 555 }
534 556
535 } // namspace content 557 } // namspace content
OLDNEW
« no previous file with comments | « content/browser/tracing/background_tracing_manager_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698