Commit 21523c78 authored by ssid's avatar ssid Committed by Commit bot

[tracing] The CPU profiler should only be enabled for specific modes of tracing

We have different modes of tracing: recording, event callback and
filtering. The cpu profiler should not be enabled when tracing is
enabled with filtering mode.

BUG=688651

Review-Url: https://codereview.chromium.org/2676403002
Cr-Commit-Position: refs/heads/master@{#43119}
parent 91b79fb7
......@@ -8,9 +8,6 @@
#include "src/tracing/trace-event.h"
#include "src/v8.h"
#define PROFILER_TRACE_CATEGORY_ENABLED(cat) \
(*TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT(cat)))
namespace v8 {
std::unique_ptr<TracingCpuProfiler> TracingCpuProfiler::Create(
......@@ -25,8 +22,9 @@ namespace internal {
TracingCpuProfilerImpl::TracingCpuProfilerImpl(Isolate* isolate)
: isolate_(isolate), profiling_enabled_(false) {
// Make sure tracing system notices profiler categories.
PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler");
PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler.hires");
TRACE_EVENT_WARMUP_CATEGORY(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler"));
TRACE_EVENT_WARMUP_CATEGORY(
TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler.hires"));
V8::GetCurrentPlatform()->AddTraceStateObserver(this);
}
......@@ -36,7 +34,10 @@ TracingCpuProfilerImpl::~TracingCpuProfilerImpl() {
}
void TracingCpuProfilerImpl::OnTraceEnabled() {
if (!PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler")) return;
bool enabled;
TRACE_EVENT_CATEGORY_GROUP_ENABLED(
TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler"), &enabled);
if (!enabled) return;
profiling_enabled_ = true;
isolate_->RequestInterrupt(
[](v8::Isolate*, void* data) {
......@@ -59,8 +60,10 @@ void TracingCpuProfilerImpl::OnTraceDisabled() {
void TracingCpuProfilerImpl::StartProfiling() {
base::LockGuard<base::Mutex> lock(&mutex_);
if (!profiling_enabled_ || profiler_) return;
int sampling_interval_us =
PROFILER_TRACE_CATEGORY_ENABLED("v8.cpu_profiler.hires") ? 100 : 1000;
bool enabled;
TRACE_EVENT_CATEGORY_GROUP_ENABLED(
TRACE_DISABLED_BY_DEFAULT("v8.cpu_profiler.hires"), &enabled);
int sampling_interval_us = enabled ? 100 : 1000;
profiler_.reset(new CpuProfiler(isolate_));
profiler_->set_sampling_interval(
base::TimeDelta::FromMicroseconds(sampling_interval_us));
......
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