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

Unified Diff: runtime/vm/profiler.cc

Issue 1820013002: Remember thread's task when sampling use it when filtering (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index 1b589d91a2c924f9a386d2a587a294ca09ad9e36..b19df91d4651da308c42e66ef9f1477bb88214f5 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -307,6 +307,12 @@ bool SampleFilter::TimeFilterSample(Sample* sample) {
}
+bool SampleFilter::TaskFilterSample(Sample* sample) {
+ const intptr_t task = static_cast<intptr_t>(sample->thread_task());
+ return (task & thread_task_mask_) != 0;
+}
+
+
ClearProfileVisitor::ClearProfileVisitor(Isolate* isolate)
: SampleVisitor(isolate) {
}
@@ -844,10 +850,7 @@ static Sample* SetupSample(Thread* thread,
#endif
sample->set_vm_tag(vm_tag);
sample->set_user_tag(isolate->user_tag());
- // TODO(rmacnak): Consider tracking the current Task kind so the profiler
- // can say the program spent x% of cpu time in the main thread, GC,
- // background compilation, etc.
- sample->set_is_mutator_thread(thread->IsMutatorThread());
+ sample->set_thread_task(thread->task_kind());
return sample;
}
@@ -989,6 +992,11 @@ void Profiler::SampleThread(Thread* thread,
return;
}
+ // Thread is not doing VM work.
+ if (thread->task_kind() == Thread::kUnknownTask) {
+ return;
+ }
+
uword stack_lower = 0;
uword stack_upper = 0;
if (!GetAndValidateIsolateStackBounds(thread,
@@ -1223,6 +1231,10 @@ ProcessedSampleBuffer* SampleBuffer::BuildProcessedSampleBuffer(
// Did not pass time filter.
continue;
}
+ if (!filter->TaskFilterSample(sample)) {
+ // Did not pass task filter.
+ continue;
+ }
if (!filter->FilterSample(sample)) {
// Did not pass filter.
continue;

Powered by Google App Engine
This is Rietveld 408576698