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

Side by Side Diff: pkg/front_end/tool/perf.dart

Issue 2562923002: Use sdk summaries in front_end/kernel_generator. (Closed)
Patch Set: lint: dartfmt Created 4 years 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 unified diff | Download patch
« no previous file with comments | « pkg/front_end/lib/kernel_generator.dart ('k') | pkg/kernel/lib/analyzer/loader.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// An entrypoint used to run portions of front_end and measure its performance. 5 /// An entrypoint used to run portions of front_end and measure its performance.
6 library front_end.tool.perf; 6 library front_end.tool.perf;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io' show exit, stderr; 9 import 'dart:io' show exit, stderr;
10 10
11 import 'package:analyzer/dart/ast/ast.dart'; 11 import 'package:analyzer/dart/ast/ast.dart';
12 import 'package:analyzer/error/listener.dart'; 12 import 'package:analyzer/error/listener.dart';
13 import 'package:analyzer/file_system/file_system.dart' show ResourceUriResolver; 13 import 'package:analyzer/file_system/file_system.dart' show ResourceUriResolver;
14 import 'package:analyzer/file_system/physical_file_system.dart' 14 import 'package:analyzer/file_system/physical_file_system.dart'
15 show PhysicalResourceProvider; 15 show PhysicalResourceProvider;
16 import 'package:analyzer/source/package_map_resolver.dart'; 16 import 'package:analyzer/source/package_map_resolver.dart';
17 import 'package:analyzer/src/context/builder.dart'; 17 import 'package:analyzer/src/context/builder.dart';
18 import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk; 18 import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk;
19 import 'package:analyzer/src/generated/parser.dart'; 19 import 'package:analyzer/src/generated/parser.dart';
20 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
21 import 'package:analyzer/src/generated/source_io.dart'; 21 import 'package:analyzer/src/generated/source_io.dart';
22 import 'package:analyzer/src/summary/format.dart'; 22 import 'package:analyzer/src/summary/format.dart';
23 import 'package:analyzer/src/summary/idl.dart'; 23 import 'package:analyzer/src/summary/idl.dart';
24 import 'package:analyzer/src/summary/link.dart'; 24 import 'package:analyzer/src/summary/link.dart';
25 import 'package:analyzer/src/summary/summarize_ast.dart'; 25 import 'package:analyzer/src/summary/summarize_ast.dart';
26 import 'package:kernel/analyzer/loader.dart'; 26 import 'package:kernel/analyzer/loader.dart';
27 import 'package:kernel/kernel.dart'; 27 import 'package:kernel/kernel.dart';
28 import 'package:package_config/discovery.dart'; 28 import 'package:package_config/discovery.dart';
29 29
30 import 'package:front_end/compiler_options.dart';
31 import 'package:front_end/kernel_generator.dart';
30 import 'package:front_end/src/scanner/reader.dart'; 32 import 'package:front_end/src/scanner/reader.dart';
31 import 'package:front_end/src/scanner/scanner.dart'; 33 import 'package:front_end/src/scanner/scanner.dart';
32 import 'package:front_end/src/scanner/token.dart'; 34 import 'package:front_end/src/scanner/token.dart';
33 35
34 /// Cumulative total number of chars scanned. 36 /// Cumulative total number of chars scanned.
35 int scanTotalChars = 0; 37 int scanTotalChars = 0;
36 38
37 /// Cumulative time spent scanning. 39 /// Cumulative time spent scanning.
38 Stopwatch scanTimer = new Stopwatch(); 40 Stopwatch scanTimer = new Stopwatch();
39 41
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // TODO(sigmund): replace the warmup with instrumented snapshots. 75 // TODO(sigmund): replace the warmup with instrumented snapshots.
74 for (int i = 0; i < 10; i++) parseFiles(files); 76 for (int i = 0; i < 10; i++) parseFiles(files);
75 }, 77 },
76 'kernel_gen_e2e': () async { 78 'kernel_gen_e2e': () async {
77 // TODO(sigmund): remove. This is used to compute the input size, we 79 // TODO(sigmund): remove. This is used to compute the input size, we
78 // should extract input size from frontend instead. 80 // should extract input size from frontend instead.
79 scanReachableFiles(entryUri); 81 scanReachableFiles(entryUri);
80 // TODO(sigmund): replace this warmup. Note that for very large programs, 82 // TODO(sigmund): replace this warmup. Note that for very large programs,
81 // the GC pressure on the VM seems to make this worse with time (maybe we 83 // the GC pressure on the VM seems to make this worse with time (maybe we
82 // are leaking memory?). That's why we run it twice and not 10 times. 84 // are leaking memory?). That's why we run it twice and not 10 times.
83 for (int i = 0; i < 2; i++) await generateKernel(entryUri); 85 for (int i = 0; i < 2; i++) {
86 await generateKernel(entryUri, useSdkSummary: false);
87 }
88 },
89 'kernel_gen_e2e_sum': () async {
90 // TODO(sigmund): remove. This is incorrect since it includes sizes for
91 // files that will not be loaded when using summaries. We need to extract
92 // input size from frontend instead.
93 scanReachableFiles(entryUri);
94 // TODO(sigmund): replace this warmup. Note that for very large programs,
95 // the GC pressure on the VM seems to make this worse with time (maybe we
96 // are leaking memory?). That's why we run it twice and not 10 times.
97 for (int i = 0; i < 2; i++) {
98 await generateKernel(entryUri, useSdkSummary: true, compileSdk: false);
99 }
84 }, 100 },
85 'unlinked_summarize': () async { 101 'unlinked_summarize': () async {
86 Set<Source> files = scanReachableFiles(entryUri); 102 Set<Source> files = scanReachableFiles(entryUri);
87 // TODO(sigmund): replace the warmup with instrumented snapshots. 103 // TODO(sigmund): replace the warmup with instrumented snapshots.
88 for (int i = 0; i < 10; i++) unlinkedSummarizeFiles(files); 104 for (int i = 0; i < 10; i++) unlinkedSummarizeFiles(files);
89 }, 105 },
90 'prelinked_summarize': () async { 106 'prelinked_summarize': () async {
91 Set<Source> files = scanReachableFiles(entryUri); 107 Set<Source> files = scanReachableFiles(entryUri);
92 // TODO(sigmund): replace the warmup with instrumented snapshots. 108 // TODO(sigmund): replace the warmup with instrumented snapshots.
93 for (int i = 0; i < 10; i++) prelinkedSummarizeFiles(files); 109 for (int i = 0; i < 10; i++) prelinkedSummarizeFiles(files);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 411
396 /// Report that metric [name] took [time] micro-seconds to process 412 /// Report that metric [name] took [time] micro-seconds to process
397 /// [scanTotalChars] characters. 413 /// [scanTotalChars] characters.
398 void report(String name, int time) { 414 void report(String name, int time) {
399 var sb = new StringBuffer(); 415 var sb = new StringBuffer();
400 sb.write('$name: $time us, ${time ~/ 1000} ms'); 416 sb.write('$name: $time us, ${time ~/ 1000} ms');
401 sb.write(', ${scanTotalChars * 1000 ~/ time} chars/ms'); 417 sb.write(', ${scanTotalChars * 1000 ~/ time} chars/ms');
402 print('$sb'); 418 print('$sb');
403 } 419 }
404 420
405 // TODO(sigmund): replace this once kernel is produced by the frontend directly. 421 Future<Program> generateKernel(Uri entryUri,
406 Future<Program> generateKernel(Uri entryUri) async { 422 {bool useSdkSummary: false, bool compileSdk: true}) async {
407 var dartkTimer = new Stopwatch()..start(); 423 var dartkTimer = new Stopwatch()..start();
408 var options = new DartOptions(strongMode: false, sdk: 'sdk'); 424 // TODO(sigmund): add a constructor with named args to compiler options.
409 var packages = 425 var options = new CompilerOptions()
410 await createPackages(options.packagePath, discoveryPath: entryUri.path); 426 ..strongMode = false
411 var repository = new Repository(); 427 ..compileSdk = compileSdk
412 DartLoader loader = new DartLoader(repository, options, packages); 428 ..packagesFilePath = '.packages'
413 429 ..onError = ((e) => print('${e.message}'));
414 Program program = loader.loadProgram(entryUri); 430 if (useSdkSummary) {
415 List errors = loader.errors; 431 // TODO(sigmund): adjust path based on the benchmark runner architecture.
416 if (errors.isNotEmpty) { 432 // Possibly let the runner make the file available at an architecture
417 const int errorLimit = 100; 433 // independent location.
418 stderr.writeln(errors.take(errorLimit).join('\n')); 434 options.sdkSummary = 'out/ReleaseX64/dart-sdk/lib/_internal/spec.sum';
419 if (errors.length > errorLimit) { 435 } else {
420 stderr.writeln('[error] ${errors.length - errorLimit} errors not shown'); 436 options.sdkPath = 'sdk';
421 }
422 } 437 }
438 Program program = await kernelForProgram(entryUri, options);
423 dartkTimer.stop(); 439 dartkTimer.stop();
424 report("kernel_gen_e2e", dartkTimer.elapsedMicroseconds); 440 var suffix = useSdkSummary ? "_sum" : "";
441 report("kernel_gen_e2e${suffix}", dartkTimer.elapsedMicroseconds);
425 return program; 442 return program;
426 } 443 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/kernel_generator.dart ('k') | pkg/kernel/lib/analyzer/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698