Commit 84fec426 authored by alph's avatar alph Committed by Commit bot

Revert of Revert of Unflake V8 sampling profiler tests. (patchset #1 id:1 of...

Revert of Revert of Unflake V8 sampling profiler tests. (patchset #1 id:1 of https://codereview.chromium.org/1017183004/)

Reason for revert:
Suspecting goma flake. Relanding.

Original issue's description:
> Revert of Unflake V8 sampling profiler tests. (patchset #1 id:1 of https://codereview.chromium.org/1032633002/)
>
> Reason for revert:
> Broke compilation on Mac Builder:
> https://build.chromium.org/p/chromium.mac/builders/Mac%20Builder/builds/19512/steps/compile/logs/stdio
>
> when compiling content/renderer/devtools/v8_sampling_profiler_browsertest.cc
>
> Original issue's description:
> > Unflake V8 sampling profiler tests.
> >
> > BUG=406277
> >
> > Committed: https://crrev.com/d6493ce2a4ed6f346a31597ac27748a3429a1d95
> > Cr-Commit-Position: refs/heads/master@{#321970}
>
> TBR=yurys@chromium.org,alph@chromium.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=406277
>
> Committed: https://crrev.com/3703085199a63732add21d955c6280765e3c480e
> Cr-Commit-Position: refs/heads/master@{#321975}

TBR=yurys@chromium.org,pneubeck@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=406277

Review URL: https://codereview.chromium.org/1029353002

Cr-Commit-Position: refs/heads/master@{#321977}
parent 0186dcd1
...@@ -117,9 +117,16 @@ class Sampler { ...@@ -117,9 +117,16 @@ class Sampler {
void DoSample(const v8::RegisterState& state); void DoSample(const v8::RegisterState& state);
void SetEventsToCollectForTest(int code_added_events, int sample_events) {
code_added_events_to_collect_for_test_ = code_added_events;
sample_events_to_collect_for_test_ = sample_events;
}
bool EventsCollectedForTest() const { bool EventsCollectedForTest() const {
return base::subtle::NoBarrier_Load(&code_added_events_count_) != 0 || return base::subtle::NoBarrier_Load(&code_added_events_count_) >=
base::subtle::NoBarrier_Load(&samples_count_) != 0; code_added_events_to_collect_for_test_ &&
base::subtle::NoBarrier_Load(&samples_count_) >=
sample_events_to_collect_for_test_;
} }
private: private:
...@@ -142,6 +149,8 @@ class Sampler { ...@@ -142,6 +149,8 @@ class Sampler {
scoped_ptr<SamplingQueue> samples_data_; scoped_ptr<SamplingQueue> samples_data_;
base::subtle::Atomic32 code_added_events_count_; base::subtle::Atomic32 code_added_events_count_;
base::subtle::Atomic32 samples_count_; base::subtle::Atomic32 samples_count_;
int code_added_events_to_collect_for_test_;
int sample_events_to_collect_for_test_;
static base::LazyInstance<base::ThreadLocalPointer<Sampler>>::Leaky static base::LazyInstance<base::ThreadLocalPointer<Sampler>>::Leaky
tls_instance_; tls_instance_;
...@@ -155,7 +164,9 @@ Sampler::Sampler() ...@@ -155,7 +164,9 @@ Sampler::Sampler()
thread_handle_(Sampler::GetCurrentThreadHandle()), thread_handle_(Sampler::GetCurrentThreadHandle()),
isolate_(Isolate::GetCurrent()), isolate_(Isolate::GetCurrent()),
code_added_events_count_(0), code_added_events_count_(0),
samples_count_(0) { samples_count_(0),
code_added_events_to_collect_for_test_(0),
sample_events_to_collect_for_test_(0) {
DCHECK(isolate_); DCHECK(isolate_);
DCHECK(!GetInstance()); DCHECK(!GetInstance());
tls_instance_.Pointer()->Set(this); tls_instance_.Pointer()->Set(this);
...@@ -213,7 +224,6 @@ void Sampler::DoSample(const v8::RegisterState& state) { ...@@ -213,7 +224,6 @@ void Sampler::DoSample(const v8::RegisterState& state) {
return; return;
record->Collect(isolate_, timestamp, state); record->Collect(isolate_, timestamp, state);
samples_data_->FinishEnqueue(); samples_data_->FinishEnqueue();
base::subtle::NoBarrier_AtomicIncrement(&samples_count_, 1);
} }
void Sampler::InjectPendingEvents() { void Sampler::InjectPendingEvents() {
...@@ -225,6 +235,7 @@ void Sampler::InjectPendingEvents() { ...@@ -225,6 +235,7 @@ void Sampler::InjectPendingEvents() {
record->ToTraceFormat()); record->ToTraceFormat());
samples_data_->Remove(); samples_data_->Remove();
record = samples_data_->Peek(); record = samples_data_->Peek();
base::subtle::NoBarrier_AtomicIncrement(&samples_count_, 1);
} }
} }
...@@ -548,7 +559,10 @@ void V8SamplingProfiler::OnTraceLogDisabled() { ...@@ -548,7 +559,10 @@ void V8SamplingProfiler::OnTraceLogDisabled() {
sampling_thread_.reset(); sampling_thread_.reset();
} }
void V8SamplingProfiler::EnableSamplingEventForTesting() { void V8SamplingProfiler::EnableSamplingEventForTesting(int code_added_events,
int sample_events) {
render_thread_sampler_->SetEventsToCollectForTest(code_added_events,
sample_events);
waitable_event_for_testing_.reset(new base::WaitableEvent(false, false)); waitable_event_for_testing_.reset(new base::WaitableEvent(false, false));
} }
......
...@@ -26,7 +26,7 @@ class CONTENT_EXPORT V8SamplingProfiler final ...@@ -26,7 +26,7 @@ class CONTENT_EXPORT V8SamplingProfiler final
void OnTraceLogEnabled() override; void OnTraceLogEnabled() override;
void OnTraceLogDisabled() override; void OnTraceLogDisabled() override;
void EnableSamplingEventForTesting(); void EnableSamplingEventForTesting(int code_added_events, int sample_events);
void WaitSamplingEventForTesting(); void WaitSamplingEventForTesting();
private: private:
......
...@@ -77,9 +77,10 @@ class V8SamplingProfilerTest : public RenderViewTest { ...@@ -77,9 +77,10 @@ class V8SamplingProfilerTest : public RenderViewTest {
flush_complete_event->Signal(); flush_complete_event->Signal();
} }
void CollectTrace() { void CollectTrace(int code_added_events, int sample_events) {
TraceLog* trace_log = TraceLog::GetInstance(); TraceLog* trace_log = TraceLog::GetInstance();
sampling_profiler_->EnableSamplingEventForTesting(); sampling_profiler_->EnableSamplingEventForTesting(code_added_events,
sample_events);
trace_log->SetEnabled( trace_log->SetEnabled(
CategoryFilter(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile")), CategoryFilter(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile")),
TraceLog::RECORDING_MODE, TraceOptions()); TraceLog::RECORDING_MODE, TraceOptions());
...@@ -129,7 +130,7 @@ class V8SamplingProfilerTest : public RenderViewTest { ...@@ -129,7 +130,7 @@ class V8SamplingProfilerTest : public RenderViewTest {
#endif #endif
TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingEventFired)) { TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingEventFired)) {
sampling_profiler_->EnableSamplingEventForTesting(); sampling_profiler_->EnableSamplingEventForTesting(0, 0);
TraceLog::GetInstance()->SetEnabled( TraceLog::GetInstance()->SetEnabled(
CategoryFilter(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile")), CategoryFilter(TRACE_DISABLED_BY_DEFAULT("v8.cpu_profile")),
TraceLog::RECORDING_MODE, TraceOptions()); TraceLog::RECORDING_MODE, TraceOptions());
...@@ -139,14 +140,14 @@ TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingEventFired)) { ...@@ -139,14 +140,14 @@ TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingEventFired)) {
} }
TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingJitCodeEventsCollected)) { TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingJitCodeEventsCollected)) {
CollectTrace(); CollectTrace(1, 0);
int jit_code_added_events_count = CountEvents("JitCodeAdded"); int jit_code_added_events_count = CountEvents("JitCodeAdded");
CHECK_LT(0, jit_code_added_events_count); CHECK_LT(0, jit_code_added_events_count);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingSamplesCollected)) { TEST_F(V8SamplingProfilerTest, MAYBE(V8SamplingSamplesCollected)) {
CollectTrace(); CollectTrace(0, 1);
int sample_events_count = CountEvents("V8Sample"); int sample_events_count = CountEvents("V8Sample");
CHECK_LT(0, sample_events_count); CHECK_LT(0, sample_events_count);
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
......
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