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

Unified Diff: runtime/bin/vmservice/vmservice_io.dart

Issue 533073005: Reduce service isolate startup time from ~80ms to ~30ms (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | « runtime/bin/vmservice/resources.dart ('k') | runtime/bin/vmservice_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/vmservice_io.dart
diff --git a/runtime/bin/vmservice/vmservice_io.dart b/runtime/bin/vmservice/vmservice_io.dart
index 399b941dfd797dfb85fe335fe4a22fd7ed808fb5..c04d485dbf27a20b724cdf7187ad3f6d4f45f5f9 100644
--- a/runtime/bin/vmservice/vmservice_io.dart
+++ b/runtime/bin/vmservice/vmservice_io.dart
@@ -8,7 +8,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:isolate';
-import 'dart:mirrors';
import 'dart:vmservice';
part 'resources.dart';
@@ -26,53 +25,47 @@ bool _isWindows = false;
Server server;
Future<Server> serverFuture;
-// The VM service instance.
-VMService service;
+void _bootServer() {
+ // Load resources.
+ _triggerResourceLoad();
+ // Lazily create service.
+ var service = new VMService();
+ // Lazily create server.
+ server = new Server(service, _ip, _port);
+}
+
+void _clearFuture(_) {
+ serverFuture = null;
+}
void _onSignal(ProcessSignal signal) {
if (serverFuture != null) {
// Still waiting.
return;
}
+ if (server == null) {
+ _bootServer();
+ }
// Toggle HTTP server.
if (server.running) {
- serverFuture = server.shutdown(true).then((_) {
- serverFuture = null;
- });
+ serverFuture = server.shutdown(true).then(_clearFuture);
} else {
- serverFuture = server.startup().then((_) {
- serverFuture = null;
- });
+ serverFuture = server.startup().then(_clearFuture);
}
}
-void registerSignalHandler() {
+void _registerSignalHandler(Stream signalWatch(ProcessSignal signal)) {
if (_isWindows) {
// Cannot register for signals on Windows.
return;
}
- bool useSIGQUIT = true;
- // Listen for SIGQUIT.
- if (useSIGQUIT) {
- var io = currentMirrorSystem().findLibrary(const Symbol('dart.io'));
- var c = MirrorSystem.getSymbol('_ProcessUtils', io);
- var m = MirrorSystem.getSymbol('_watchSignalInternal', io);
- var processUtils = io.declarations[c];
- processUtils.invoke(m, [ProcessSignal.SIGQUIT]).reflectee.listen(_onSignal);
- } else {
- ProcessSignal.SIGUSR1.watch().listen(_onSignal);
- }
+ signalWatch(ProcessSignal.SIGQUIT).listen(_onSignal);
}
-
-main() {
- // Get VMService.
- service = new VMService();
- // Start HTTP server.
- server = new Server(service, _ip, _port);
+main(Stream signalWatch(ProcessSignal signal)) {
if (_autoStart) {
+ _bootServer();
server.startup();
}
-
- registerSignalHandler();
+ _registerSignalHandler(signalWatch);
}
« no previous file with comments | « runtime/bin/vmservice/resources.dart ('k') | runtime/bin/vmservice_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698