fuchsia: Delete unused compilation_trace code (flutter/engine#20535)

This commit is contained in:
David Worsham
2021-06-03 15:44:01 -07:00
committed by GitHub
parent 6abe0e140c
commit 90b1f10ab7
7 changed files with 2 additions and 6230 deletions

View File

@@ -1335,7 +1335,6 @@ FILE: ../../../flutter/shell/platform/fuchsia/dart_runner/vmservice/meta/vmservi
FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge.h
FILE: ../../../flutter/shell/platform/fuchsia/flutter/accessibility_bridge_unittest.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/collect_traces.dart
FILE: ../../../flutter/shell/platform/fuchsia/flutter/component.cc
FILE: ../../../flutter/shell/platform/fuchsia/flutter/component.h
FILE: ../../../flutter/shell/platform/fuchsia/flutter/component_unittest.cc

View File

@@ -38,12 +38,7 @@ template("create_kernel_core_snapshot") {
deps = [ ":kernel_platform_files" ]
platform_dill = "$root_out_dir/dart_runner_patched_sdk/platform_strong.dill"
compilation_trace =
"//flutter/shell/platform/fuchsia/flutter/compilation_trace.txt"
inputs = [
platform_dill,
compilation_trace,
]
inputs = [ platform_dill ]
vm_snapshot_data = "$target_gen_dir/vm_data${product_suffix}.bin"
vm_snapshot_instructions =
@@ -73,8 +68,6 @@ template("create_kernel_core_snapshot") {
"--enable_mirrors=false",
"--deterministic",
"--snapshot_kind=core-jit",
"--load_compilation_trace=" +
rebase_path(compilation_trace, root_build_dir),
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
"--vm_snapshot_instructions=" +
rebase_path(vm_snapshot_instructions, root_build_dir),

View File

@@ -1,68 +0,0 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.9
import 'dart:io';
import 'dart:convert';
bool includeFunction(String function) {
return function.startsWith("dart:") ||
function.startsWith("package:flutter/") ||
function.startsWith("package:vector_math/");
}
main(List<String> args) async {
if (args.length != 1) {
print("Usage:\n"
" fx syslog | dart topaz/runtime/flutter_runner/collect_traces.dart output.txt");
exitCode = 1;
return;
}
var functionCounts = Map<String, int>();
ProcessSignal.sigint.watch().listen((_) {
var functions = List<String>();
// TODO(flutter): Investigate consensus functions to avoid bloat.
var minimumCount = 1;
functionCounts.forEach((String function, int count) {
if (count >= minimumCount) {
functions.add(function);
}
});
functions.sort();
var sb = StringBuffer();
for (var function in functions) {
sb.writeln(function);
}
File(args[0]).writeAsString(sb.toString(), flush: true).then((_) { exit(0); });
});
final stdinAsLines = LineSplitter().bind(Utf8Decoder().bind(stdin));
await for (final line in stdinAsLines) {
final marker = "compilation-trace: ";
final markerPosition = line.indexOf(marker);
if (markerPosition == -1) {
continue;
}
final function = line.substring(markerPosition + marker.length);
if (!includeFunction(function)) {
continue;
}
print(function);
var count = functionCounts[function];
if (count == null) {
count = 1;
} else {
count++;
}
functionCounts[function] = count;
}
}

View File

@@ -1,10 +0,0 @@
The compilation trace lists functions that will be compiled in the core
snapshot. It is derived by unioning the output of Dart_SaveCompilationTrace
after startup from a few apps.
To update this trace.
- In //topaz/runtime/flutter_runner/engine.cc, change kCompilationTraceDelayInSeconds to a non-zero value.
- Re-build.
- Run `fx syslog | dart topaz/runtime/flutter_runner/collect_traces.dart topaz/runtime/flutter_runner/compilation_trace.txt`
- Boot and run a few apps, making sure to exercise the interesting paths before the timer set above expires.
- Send SIGINT (Ctrl-C) to collect_traces.dart.

View File

@@ -538,53 +538,6 @@ std::optional<uint32_t> Engine::GetEngineReturnCode() const {
return code;
}
static void CreateCompilationTrace(Dart_Isolate isolate) {
Dart_EnterIsolate(isolate);
{
Dart_EnterScope();
uint8_t* trace = nullptr;
intptr_t trace_length = 0;
Dart_Handle result = Dart_SaveCompilationTrace(&trace, &trace_length);
tonic::LogIfError(result);
for (intptr_t start = 0; start < trace_length;) {
intptr_t end = start;
while ((end < trace_length) && trace[end] != '\n')
end++;
std::string line(reinterpret_cast<char*>(&trace[start]), end - start);
FML_LOG(INFO) << "compilation-trace: " << line;
start = end + 1;
}
Dart_ExitScope();
}
// Re-enter Dart scope to release the compilation trace's memory.
{
Dart_EnterScope();
uint8_t* feedback = nullptr;
intptr_t feedback_length = 0;
Dart_Handle result = Dart_SaveTypeFeedback(&feedback, &feedback_length);
tonic::LogIfError(result);
const std::string kTypeFeedbackFile = "/data/dart_type_feedback.bin";
if (dart_utils::WriteFile(kTypeFeedbackFile,
reinterpret_cast<const char*>(feedback),
feedback_length)) {
FML_LOG(INFO) << "Dart type feedback written to " << kTypeFeedbackFile;
} else {
FML_LOG(ERROR) << "Could not write Dart type feedback to "
<< kTypeFeedbackFile;
}
Dart_ExitScope();
}
Dart_ExitIsolate();
}
void Engine::OnMainIsolateStart() {
if (!isolate_configurator_ ||
!isolate_configurator_->ConfigureCurrentIsolate()) {
@@ -593,20 +546,6 @@ void Engine::OnMainIsolateStart() {
}
FML_DLOG(INFO) << "Main isolate for engine '" << thread_label_
<< "' was started.";
const intptr_t kCompilationTraceDelayInSeconds = 0;
if (kCompilationTraceDelayInSeconds != 0) {
Dart_Isolate isolate = Dart_CurrentIsolate();
FML_CHECK(isolate);
shell_->GetTaskRunners().GetUITaskRunner()->PostDelayedTask(
[engine = shell_->GetEngine(), isolate]() {
if (!engine) {
return;
}
CreateCompilationTrace(isolate);
},
fml::TimeDelta::FromSeconds(kCompilationTraceDelayInSeconds));
}
}
void Engine::OnMainIsolateShutdown() {

View File

@@ -42,12 +42,7 @@ template("core_snapshot") {
platform_dill =
"$root_out_dir/flutter_runner_patched_sdk/platform_strong.dill"
compilation_trace =
"//flutter/shell/platform/fuchsia/flutter/compilation_trace.txt"
inputs = [
platform_dill,
compilation_trace,
]
inputs = [ platform_dill ]
vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot${suffix}.bin"
vm_snapshot_instructions =
@@ -77,8 +72,6 @@ template("core_snapshot") {
"--enable_mirrors=false",
"--deterministic",
"--snapshot_kind=core-jit",
"--load_compilation_trace=" +
rebase_path(compilation_trace, root_build_dir),
"--vm_snapshot_data=" + rebase_path(vm_snapshot_data, root_build_dir),
"--vm_snapshot_instructions=" +
rebase_path(vm_snapshot_instructions, root_build_dir),