[profiler] Introduce lightweight mode for Rutime Call Stats collection.

In the lightweight mode it only maintains pseudo stack and does not
collect timing information. It can be used in the sampling mode.

BUG=chromium:660428

Review-Url: https://codereview.chromium.org/2472193002
Cr-Commit-Position: refs/heads/master@{#40812}
This commit is contained in:
alph 2016-11-07 10:13:25 -08:00 committed by Commit bot
parent 32ec567df1
commit c57e54b389
3 changed files with 17 additions and 6 deletions

View File

@ -17,6 +17,7 @@
#include "src/runtime/runtime.h"
#include "src/tracing/trace-event.h"
#include "src/tracing/traced-value.h"
#include "src/tracing/tracing-category-observer.h"
namespace v8 {
namespace internal {
@ -507,10 +508,14 @@ class RuntimeCallTimer {
inline void Start(RuntimeCallCounter* counter, RuntimeCallTimer* parent) {
counter_ = counter;
parent_.SetValue(parent);
timer_.Start();
if (FLAG_runtime_stats !=
v8::tracing::TracingCategoryObserver::ENABLED_BY_SAMPLING) {
timer_.Start();
}
}
inline RuntimeCallTimer* Stop() {
if (!timer_.IsStarted()) return parent();
base::TimeDelta delta = timer_.Elapsed();
timer_.Stop();
counter_->count++;

View File

@ -18,6 +18,8 @@ void TracingCategoryObserver::SetUp() {
v8::internal::V8::GetCurrentPlatform()->AddTraceStateObserver(
TracingCategoryObserver::instance_);
TRACE_EVENT_WARMUP_CATEGORY(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats"));
TRACE_EVENT_WARMUP_CATEGORY(
TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling"));
}
void TracingCategoryObserver::TearDown() {
@ -33,10 +35,16 @@ void TracingCategoryObserver::OnTraceEnabled() {
if (enabled) {
v8::internal::FLAG_runtime_stats |= ENABLED_BY_TRACING;
}
TRACE_EVENT_CATEGORY_GROUP_ENABLED(
TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling"), &enabled);
if (enabled) {
v8::internal::FLAG_runtime_stats |= ENABLED_BY_SAMPLING;
}
}
void TracingCategoryObserver::OnTraceDisabled() {
v8::internal::FLAG_runtime_stats &= ~ENABLED_BY_TRACING;
v8::internal::FLAG_runtime_stats &=
~(ENABLED_BY_TRACING | ENABLED_BY_SAMPLING);
}
} // namespace tracing

View File

@ -6,7 +6,6 @@
#define V8_TRACING_TRACING_CATEGORY_OBSERVER_H_
#include "include/v8-platform.h"
#include "src/base/lazy-instance.h"
namespace v8 {
namespace tracing {
@ -16,6 +15,7 @@ class TracingCategoryObserver : public Platform::TraceStateObserver {
enum Mode {
ENABLED_BY_NATIVE = 1 << 0,
ENABLED_BY_TRACING = 1 << 1,
ENABLED_BY_SAMPLING = 1 << 2,
};
static void SetUp();
@ -25,13 +25,11 @@ class TracingCategoryObserver : public Platform::TraceStateObserver {
void OnTraceEnabled() final;
void OnTraceDisabled() final;
TracingCategoryObserver() {}
~TracingCategoryObserver() {}
private:
static TracingCategoryObserver* instance_;
};
} // namespace tracing
} // namespace v8
#endif // V8_TRACING_TRACING_CATEGORY_OBSERVER_H_