Commit 610fe289 authored by fmeawad's avatar fmeawad Committed by Commit bot

[Tracing] Remove State Sampling Profiling

The state sampling was implemented in chrome, we had an interface for it
V8 but it was not implemented yet.
The chrome version version has been removed in
https://codereview.chromium.org/2406703002/
Therefore following up with its removal in V8 as well.

This CL can land independent of the Chromium related CL.

R=primiano@chromium.org,alph@chromium.org

Review-Url: https://codereview.chromium.org/2410523002
Cr-Commit-Position: refs/heads/master@{#40232}
parent 479e30c0
......@@ -185,17 +185,12 @@ class V8_PLATFORM_EXPORT TraceConfig {
static TraceConfig* CreateDefaultTraceConfig();
TraceConfig()
: enable_sampling_(false),
enable_systrace_(false),
enable_argument_filter_(false) {}
TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {}
TraceRecordMode GetTraceRecordMode() const { return record_mode_; }
bool IsSamplingEnabled() const { return enable_sampling_; }
bool IsSystraceEnabled() const { return enable_systrace_; }
bool IsArgumentFilterEnabled() const { return enable_argument_filter_; }
void SetTraceRecordMode(TraceRecordMode mode) { record_mode_ = mode; }
void EnableSampling() { enable_sampling_ = true; }
void EnableSystrace() { enable_systrace_ = true; }
void EnableArgumentFilter() { enable_argument_filter_ = true; }
......@@ -206,7 +201,6 @@ class V8_PLATFORM_EXPORT TraceConfig {
private:
TraceRecordMode record_mode_;
bool enable_sampling_ : 1;
bool enable_systrace_ : 1;
bool enable_argument_filter_ : 1;
StringList included_categories_;
......
......@@ -196,7 +196,6 @@ const char kRecordContinuously[] = "record-continuously";
const char kRecordAsMuchAsPossible[] = "record-as-much-as-possible";
const char kRecordModeParam[] = "record_mode";
const char kEnableSamplingParam[] = "enable_sampling";
const char kEnableSystraceParam[] = "enable_systrace";
const char kEnableArgumentFilterParam[] = "enable_argument_filter";
const char kIncludedCategoriesParam[] = "included_categories";
......@@ -220,10 +219,6 @@ class TraceConfigParser {
trace_config->SetTraceRecordMode(
GetTraceRecordMode(isolate, context, trace_config_object));
if (GetBoolean(isolate, context, trace_config_object,
kEnableSamplingParam)) {
trace_config->EnableSampling();
}
if (GetBoolean(isolate, context, trace_config_object,
kEnableSystraceParam)) {
trace_config->EnableSystrace();
......
......@@ -49,33 +49,6 @@ enum CategoryGroupEnabledFlags {
#define TRACE_ID_WITH_SCOPE(scope, id) \
trace_event_internal::TraceID::WithScope(scope, id)
// Sets the current sample state to the given category and name (both must be
// constant strings). These states are intended for a sampling profiler.
// Implementation note: we store category and name together because we don't
// want the inconsistency/expense of storing two pointers.
// |thread_bucket| is [0..2] and is used to statically isolate samples in one
// thread from others.
#define TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(bucket_number, category, \
name) \
v8::internal::tracing::TraceEventSamplingStateScope<bucket_number>::Set( \
category "\0" name)
// Returns a current sampling state of the given bucket.
#define TRACE_EVENT_GET_SAMPLING_STATE_FOR_BUCKET(bucket_number) \
v8::internal::tracing::TraceEventSamplingStateScope<bucket_number>::Current()
// Creates a scope of a sampling state of the given bucket.
//
// { // The sampling state is set within this scope.
// TRACE_EVENT_SAMPLING_STATE_SCOPE_FOR_BUCKET(0, "category", "name");
// ...;
// }
#define TRACE_EVENT_SCOPED_SAMPLING_STATE_FOR_BUCKET(bucket_number, category, \
name) \
v8::internal::TraceEventSamplingStateScope<bucket_number> \
traceEventSamplingScope(category "\0" name);
#define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \
*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \
(kEnabledForRecording_CategoryGroupEnabledFlags | \
......@@ -138,12 +111,6 @@ enum CategoryGroupEnabledFlags {
#define TRACE_EVENT_API_ATOMIC_STORE(var, value) \
v8::base::NoBarrier_Store(&(var), (value))
// The thread buckets for the sampling profiler.
extern TRACE_EVENT_API_ATOMIC_WORD g_trace_state[3];
#define TRACE_EVENT_API_THREAD_BUCKET(thread_bucket) \
g_trace_state[thread_bucket]
////////////////////////////////////////////////////////////////////////////////
// Implementation detail: trace event macros create temporary variables
......@@ -613,48 +580,6 @@ class ScopedTracer {
Data data_;
};
// Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly.
class ScopedTraceBinaryEfficient {
public:
ScopedTraceBinaryEfficient(const char* category_group, const char* name);
~ScopedTraceBinaryEfficient();
private:
const uint8_t* category_group_enabled_;
const char* name_;
uint64_t event_handle_;
};
// TraceEventSamplingStateScope records the current sampling state
// and sets a new sampling state. When the scope exists, it restores
// the sampling state having recorded.
template <size_t BucketNumber>
class TraceEventSamplingStateScope {
public:
explicit TraceEventSamplingStateScope(const char* category_and_name) {
previous_state_ = TraceEventSamplingStateScope<BucketNumber>::Current();
TraceEventSamplingStateScope<BucketNumber>::Set(category_and_name);
}
~TraceEventSamplingStateScope() {
TraceEventSamplingStateScope<BucketNumber>::Set(previous_state_);
}
static V8_INLINE const char* Current() {
return reinterpret_cast<const char*>(
TRACE_EVENT_API_ATOMIC_LOAD(g_trace_state[BucketNumber]));
}
static V8_INLINE void Set(const char* category_and_name) {
TRACE_EVENT_API_ATOMIC_STORE(g_trace_state[BucketNumber],
reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(
const_cast<char*>(category_and_name)));
}
private:
const char* previous_state_;
};
// Do not use directly.
class CallStatsScopedTracer {
public:
......
......@@ -14,12 +14,10 @@ namespace tracing {
TEST(TestTraceConfig) {
LocalContext env;
TraceConfig* trace_config = new TraceConfig();
trace_config->EnableSampling();
trace_config->AddIncludedCategory("v8");
trace_config->AddIncludedCategory(TRACE_DISABLED_BY_DEFAULT("v8.runtime"));
trace_config->AddExcludedCategory("v8.cpu_profile");
CHECK_EQ(trace_config->IsSamplingEnabled(), true);
CHECK_EQ(trace_config->IsSystraceEnabled(), false);
CHECK_EQ(trace_config->IsArgumentFilterEnabled(), false);
CHECK_EQ(trace_config->IsCategoryGroupEnabled("v8"), true);
......
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