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

Unified Diff: pkg/compiler/lib/src/compiler.dart

Issue 1454373002: Use Zone to correctly measure async operations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@_temporary_fletch_patches
Patch Set: Address Florian's comments Created 4 years, 11 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
« no previous file with comments | « pkg/compiler/lib/src/common/tasks.dart ('k') | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/compiler.dart
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 0bcc283efe75b538f027f0b83490fe37f70c3631..e005377e7b97de5032de2f10a8e88231daad85a0 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -32,7 +32,8 @@ import 'common/resolution.dart' show
ResolutionImpact;
import 'common/tasks.dart' show
CompilerTask,
- GenericTask;
+ GenericTask,
+ Measurer;
import 'common/work.dart' show
WorkItem;
import 'compile_time_constants.dart';
@@ -145,8 +146,12 @@ import 'world.dart' show
World;
abstract class Compiler {
+ /// Helper instance for measurements in [CompilerTask].
+ ///
+ /// Note: MUST be first field to ensure [Measurer.wallclock] is started
+ /// before other computations.
+ final Measurer measurer = new Measurer();
- final Stopwatch totalCompileTime = new Stopwatch();
int nextFreeClassId = 0;
World world;
Types types;
@@ -275,7 +280,6 @@ abstract class Compiler {
Tracer tracer;
- CompilerTask measuredTask;
LibraryElement coreLibrary;
LibraryElement asyncLibrary;
@@ -368,6 +372,8 @@ abstract class Compiler {
GenericTask reuseLibraryTask;
+ GenericTask selfTask;
+
/// The constant environment for the frontend interpretation of compile-time
/// constants.
ConstantEnvironment constants;
@@ -452,7 +458,7 @@ abstract class Compiler {
List<String> strips: const [],
Backend makeBackend(Compiler compiler)})
: this.disableTypeInferenceFlag =
- disableTypeInferenceFlag || !emitJavaScript,
+ disableTypeInferenceFlag || !emitJavaScript,
this.analyzeOnly =
analyzeOnly || analyzeSignaturesOnly || analyzeAllFlag,
this.analyzeSignaturesOnly = analyzeSignaturesOnly,
@@ -517,6 +523,7 @@ abstract class Compiler {
enqueuer = backend.makeEnqueuer(),
dumpInfoTask = new DumpInfoTask(this),
reuseLibraryTask = new GenericTask('Reuse library', this),
+ selfTask = new GenericTask('self', this),
];
tasks.addAll(backend.tasks);
@@ -545,18 +552,18 @@ abstract class Compiler {
//
// The resulting future will complete with true if the compilation
// succeded.
- Future<bool> run(Uri uri) {
- totalCompileTime.start();
+ Future<bool> run(Uri uri) => selfTask.measureSubtask("Compiler.run", () {
+ measurer.startWallClock();
return new Future.sync(() => runInternal(uri))
.catchError((error) => _reporter.onError(uri, error))
.whenComplete(() {
tracer.close();
- totalCompileTime.stop();
+ measurer.stopWallClock();
}).then((_) {
return !compilationFailed;
});
- }
+ });
/// This method is called immediately after the [LibraryElement] [library] has
/// been created.
@@ -960,7 +967,9 @@ abstract class Compiler {
}
/// Performs the compilation when all libraries have been loaded.
- void compileLoadedLibraries() {
+ void compileLoadedLibraries()
+ => selfTask.measureSubtask("Compiler.compileLoadedLibraries", () {
+
computeMain();
mirrorUsageAnalyzerTask.analyzeUsage(mainApp);
@@ -1057,7 +1066,7 @@ abstract class Compiler {
}
checkQueues();
- }
+ });
void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) {
void enqueueAll(Element element) {
@@ -1094,15 +1103,20 @@ abstract class Compiler {
/**
* Empty the [world] queue.
*/
- void emptyQueue(Enqueuer world) {
+ void emptyQueue(Enqueuer world)
+ => selfTask.measureSubtask("Compiler.emptyQueue", () {
world.forEach((WorkItem work) {
- reporter.withCurrentElement(work.element, () {
- world.applyImpact(work.element, work.run(this, world));
- });
+ reporter.withCurrentElement(
+ work.element, () => selfTask.measureSubtask("world.applyImpact", () {
+ world.applyImpact(
+ work.element,
+ selfTask.measureSubtask("work.run", () => work.run(this, world)));
+ }));
});
- }
+ });
- void processQueue(Enqueuer world, Element main) {
+ void processQueue(Enqueuer world, Element main)
+ => selfTask.measureSubtask("Compiler.processQueue", () {
world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries);
if (main != null && !main.isMalformed) {
FunctionElement mainMethod = main;
@@ -1127,7 +1141,7 @@ abstract class Compiler {
world.queueIsClosed = true;
backend.onQueueClosed();
assert(compilationFailed || world.checkNoEnqueuedInvokedInstanceMethods());
- }
+ });
/**
* Perform various checks of the queues. This includes checking that
@@ -1169,7 +1183,8 @@ abstract class Compiler {
}
}
- WorldImpact analyzeElement(Element element) {
+ WorldImpact analyzeElement(Element element)
+ => selfTask.measureSubtask("Compiler.analyzeElement", () {
assert(invariant(element,
element.impliesType ||
element.isField ||
@@ -1182,10 +1197,10 @@ abstract class Compiler {
message: 'Element $element is not analyzable.'));
assert(invariant(element, element.isDeclaration));
return resolution.computeWorldImpact(element);
- }
+ });
- WorldImpact analyze(ResolutionWorkItem work,
- ResolutionEnqueuer world) {
+ WorldImpact analyze(ResolutionWorkItem work, ResolutionEnqueuer world)
+ => selfTask.measureSubtask("Compiler.analyze", () {
assert(invariant(work.element, identical(world, enqueuer.resolution)));
assert(invariant(work.element, !work.isAnalyzed,
message: 'Element ${work.element} has already been analyzed'));
@@ -1207,7 +1222,7 @@ abstract class Compiler {
backend.onElementResolved(element, element.resolvedAst.elements);
world.registerProcessedElement(element);
return worldImpact;
- }
+ });
WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) {
assert(invariant(work.element, identical(world, enqueuer.codegen)));
« no previous file with comments | « pkg/compiler/lib/src/common/tasks.dart ('k') | pkg/compiler/lib/src/dump_info.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698