Disable profiling by default. Allow enabling via --enable-dart-profiling. (flutter/engine#3238)

This commit is contained in:
Chinmay Garde 2016-11-21 11:50:42 -08:00 committed by GitHub
parent 85abbfaa3e
commit 40ae490ca8
5 changed files with 34 additions and 19 deletions

View File

@ -20,6 +20,7 @@ struct Settings {
bool start_paused = false;
bool trace_startup = false;
bool endless_trace_buffer = false;
bool enable_dart_profiling = false;
std::string aot_snapshot_path;
std::string aot_isolate_snapshot_file_name;
std::string aot_vm_isolate_snapshot_file_name;

View File

@ -78,24 +78,6 @@ const char kSnapshotAssetKey[] = "snapshot_blob.bin";
namespace {
static const char* kDartProfilingArgs[] = {
// Dart assumes ARM devices are insufficiently powerful and sets the
// default profile period to 100Hz. This number is suitable for older
// Raspberry Pi devices but quite low for current smartphones.
"--profile_period=1000",
// Disable Dart's built in profiler when building a debug build. This
// works around a race condition that would sometimes stop a crash's
// stack trace from being printed on Android.
#ifndef NDEBUG
"--no-profiler",
#endif
#if (WTF_OS_IOS || WTF_OS_MACOSX)
// On platforms where LLDB is the primary debugger, SIGPROF signals
// overwhelm LLDB.
"--no-profiler",
#endif
};
static const char* kDartMirrorsArgs[] = {
"--enable_mirrors=false",
};
@ -555,6 +537,30 @@ static void EmbedderTimelineStopRecording() {
g_tracing_callbacks->stop_tracing_callback();
}
static std::vector<const char*> ProfilingFlags(bool enable_profiling) {
// Disable Dart's built in profiler when building a debug build. This
// works around a race condition that would sometimes stop a crash's
// stack trace from being printed on Android.
#ifndef NDEBUG
enable_profiling = false;
#endif
// We want to disable profiling by default because it overwhelms LLDB. But
// the VM enables the same by default. In either case, we have some profiling
// flags.
if (enable_profiling) {
return {
// Dart assumes ARM devices are insufficiently powerful and sets the
// default profile period to 100Hz. This number is suitable for older
// Raspberry Pi devices but quite low for current smartphones.
"--profile_period=1000",
// This is the default. But just be explicit.
"--profiler"};
} else {
return {"--no-profiler"};
}
}
void SetServiceIsolateHook(ServiceIsolateHook hook) {
FTL_CHECK(!g_service_isolate_initialized);
g_service_isolate_hook = hook;
@ -596,7 +602,11 @@ void InitDartVM() {
// it does not recognize, it exits immediately.
args.push_back("--ignore-unrecognized-flags");
PushBackAll(&args, kDartProfilingArgs, arraysize(kDartProfilingArgs));
for (const auto& profiler_flag :
ProfilingFlags(settings.enable_dart_profiling)) {
args.push_back(profiler_flag);
}
PushBackAll(&args, kDartMirrorsArgs, arraysize(kDartMirrorsArgs));
PushBackAll(&args, kDartBackgroundCompilationArgs,
arraysize(kDartBackgroundCompilationArgs));

View File

@ -144,6 +144,8 @@ void Shell::InitStandalone(std::string icu_data_path) {
}
}
settings.start_paused = command_line.HasSwitch(switches::kStartPaused);
settings.enable_dart_profiling =
command_line.HasSwitch(switches::kEnableDartProfiling);
settings.endless_trace_buffer =
command_line.HasSwitch(switches::kEndlessTraceBuffer);
settings.trace_startup = command_line.HasSwitch(switches::kTraceStartup);

View File

@ -18,6 +18,7 @@ const char kCacheDirPath[] = "cache-dir-path";
const char kDartFlags[] = "dart-flags";
const char kDeviceObservatoryPort[] = "observatory-port";
const char kDisableObservatory[] = "disable-observatory";
const char kEnableDartProfiling[] = "enable-dart-profiling";
const char kEndlessTraceBuffer[] = "endless-trace-buffer";
const char kFLX[] = "flx";
const char kHelp[] = "help";

View File

@ -19,6 +19,7 @@ extern const char kCacheDirPath[];
extern const char kDartFlags[];
extern const char kDeviceObservatoryPort[];
extern const char kDisableObservatory[];
extern const char kEnableDartProfiling[];
extern const char kEndlessTraceBuffer[];
extern const char kFLX[];
extern const char kHelp[];