Skip to content

Instantly share code, notes, and snippets.

@dcharkes
Created May 22, 2019 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcharkes/ce7427fc87a332428732c3aa4865bc0f to your computer and use it in GitHub Desktop.
Save dcharkes/ce7427fc87a332428732c3aa4865bc0f to your computer and use it in GitHub Desktop.
commit 7a971789b9407e65bd38d49b7f0335a7737bcf76
Author: Daco Harkes <dacoharkes@google.com>
Date: Wed May 22 14:33:33 2019 +0200
disable profiling mac
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 16abbaa396..84e7bb7b88 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -1305,18 +1305,12 @@ DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port,
const intptr_t kBufferLength = 512;
char method[kBufferLength];
-
- // clang-format off
intptr_t method_length = snprintf(method, kBufferLength, "{"
"\"jsonrpc\": \"2.0\","
"\"method\": \"_writeCpuProfileTimeline\","
"\"id\": \"\","
- "\"params\": {"
- " \"isolateId\": \"isolates/%" Pd64 "\","
- " \"tags\": \"None\""
- "}"
- "}", main_port);
- // clang-format on
+ "\"params\": {\"isolateId\": \"isolates/%" Pd64 "\"}"
+ "}", main_port);
ASSERT(method_length <= kBufferLength);
char* response = NULL;
diff --git a/runtime/vm/os_thread_macos.cc b/runtime/vm/os_thread_macos.cc
index 50a295288e..eecfe67bcb 100644
--- a/runtime/vm/os_thread_macos.cc
+++ b/runtime/vm/os_thread_macos.cc
@@ -14,7 +14,6 @@
#include <mach/task_info.h> // NOLINT
#include <mach/thread_act.h> // NOLINT
#include <mach/thread_info.h> // NOLINT
-#include <signal.h> // NOLINT
#include <sys/errno.h> // NOLINT
#include <sys/sysctl.h> // NOLINT
#include <sys/types.h> // NOLINT
@@ -22,7 +21,6 @@
#include "platform/address_sanitizer.h"
#include "platform/assert.h"
#include "platform/safe_stack.h"
-#include "platform/signal_blocker.h"
#include "platform/utils.h"
namespace dart {
@@ -88,20 +86,6 @@ class ThreadStartData {
DISALLOW_COPY_AND_ASSIGN(ThreadStartData);
};
-// Spawned threads inherit their spawner's signal mask. We sometimes spawn
-// threads for running Dart code from a thread that is blocking SIGPROF.
-// This function explicitly unblocks SIGPROF so the profiler continues to
-// sample this thread.
-static void UnblockSIGPROF() {
- sigset_t set;
- sigemptyset(&set);
- sigaddset(&set, SIGPROF);
- int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
- USE(r);
- ASSERT(r == 0);
- ASSERT(!CHECK_IS_BLOCKING(SIGPROF));
-}
-
// Dispatch to the thread start function provided by the caller. This trampoline
// is used to ensure that the thread is properly destroyed if the thread just
// exits.
@@ -121,7 +105,7 @@ static void* ThreadStart(void* data_ptr) {
if (thread != NULL) {
OSThread::SetCurrent(thread);
thread->set_name(name);
- UnblockSIGPROF();
+
// Call the supplied thread start function handing it its parameters.
function(parameter);
}
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index 1532bf97d6..6af3009976 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -263,14 +263,6 @@ static bool CheckCompilerDisabled(Thread* thread, JSONStream* js) {
return false;
}
-static bool CheckProfilerDisabled(Thread* thread, JSONStream* js) {
- if (Profiler::sample_buffer() == NULL) {
- js->PrintError(kFeatureDisabled, "Profiler is disabled.");
- return true;
- }
- return false;
-}
-
static bool GetIntegerId(const char* s, intptr_t* id, int base = 10) {
if ((s == NULL) || (*s == '\0')) {
// Empty string.
@@ -3833,12 +3825,13 @@ static const MethodParameter* get_cpu_profile_params[] = {
NULL,
};
+static const MethodParameter* write_cpu_profile_timeline_params[] = {
+ RUNNABLE_ISOLATE_PARAMETER,
+ NULL,
+};
+
// TODO(johnmccutchan): Rename this to GetCpuSamples.
static bool GetCpuProfile(Thread* thread, JSONStream* js) {
- if (CheckProfilerDisabled(thread, js)) {
- return true;
- }
-
Profile::TagOrder tag_order =
EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values);
intptr_t extra_tags = 0;
@@ -3863,10 +3856,6 @@ static const MethodParameter* get_cpu_profile_timeline_params[] = {
};
static bool GetCpuProfileTimeline(Thread* thread, JSONStream* js) {
- if (CheckProfilerDisabled(thread, js)) {
- return true;
- }
-
Profile::TagOrder tag_order =
EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values);
int64_t time_origin_micros =
@@ -3879,19 +3868,7 @@ static bool GetCpuProfileTimeline(Thread* thread, JSONStream* js) {
return true;
}
-static const MethodParameter* write_cpu_profile_timeline_params[] = {
- RUNNABLE_ISOLATE_PARAMETER,
- new EnumParameter("tags", true, tags_enum_names),
- new Int64Parameter("timeOriginMicros", false),
- new Int64Parameter("timeExtentMicros", false),
- NULL,
-};
-
static bool WriteCpuProfileTimeline(Thread* thread, JSONStream* js) {
- if (CheckProfilerDisabled(thread, js)) {
- return true;
- }
-
Profile::TagOrder tag_order =
EnumMapper(js->LookupParam("tags"), tags_enum_names, tags_enum_values);
int64_t time_origin_micros =
@@ -3901,7 +3878,6 @@ static bool WriteCpuProfileTimeline(Thread* thread, JSONStream* js) {
bool code_trie = BoolParameter::Parse(js->LookupParam("code"), true);
ProfilerService::AddToTimeline(tag_order, time_origin_micros,
time_extent_micros, code_trie);
- PrintSuccess(js); // The "result" is a side-effect in the timeline.
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment