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

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

Issue 874083002: add periodic delay in analysis to reduce request processing latency (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add flag to disable delay along with comments explaining why the workaround was added Created 5 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 | « no previous file | pkg/analysis_server/lib/src/get_handler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 9448ea7d143211606b3bfb6c0af856b75aace656..139048371770a77bb839b809f3741ae7d531782b 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -69,6 +69,13 @@ class AnalysisServer {
static final String VERSION = '0.0.1';
/**
+ * The number of milliseconds to perform operations before inserting
+ * a 1 millisecond delay so that the VM and dart:io can deliver content
+ * to stdin. This should be removed once the underlying problem is fixed.
+ */
+ static int performOperationDelayFreqency = 25;
+
+ /**
* The channel from which requests are received and to which responses should
* be sent.
*/
@@ -191,6 +198,15 @@ class AnalysisServer {
bool rethrowExceptions;
/**
+ * The next time (milliseconds since epoch) after which the analysis server
+ * should pause so that pending requests can be fetched by the system.
+ */
+ // Add 1 sec to prevent delay from impacting short running tests
+ int _nextPerformOperationDelayTime =
+ new DateTime.now().millisecondsSinceEpoch +
+ 1000;
+
+ /**
* Initialize a newly created server to receive requests from and send
* responses to the given [channel].
*
@@ -933,7 +949,24 @@ class AnalysisServer {
*/
void _schedulePerformOperation() {
assert(!performOperationPending);
- new Future(performOperation);
+ /*
+ * TODO (danrubel) Rip out this workaround once the underlying problem
+ * is fixed. Currently, the VM and dart:io do not deliver content
+ * on stdin in a timely manner if the event loop is busy.
+ * To work around this problem, we delay for 1 millisecond
+ * every 25 milliseconds.
+ *
+ * To disable this workaround and see the underlying problem,
+ * set performOperationDelayFreqency to zero
+ */
+ int now = new DateTime.now().millisecondsSinceEpoch;
+ if (now > _nextPerformOperationDelayTime &&
+ performOperationDelayFreqency > 0) {
+ _nextPerformOperationDelayTime = now + performOperationDelayFreqency;
+ new Future.delayed(new Duration(milliseconds: 1), performOperation);
+ } else {
+ new Future(performOperation);
+ }
performOperationPending = true;
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/get_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698