Chromium Code Reviews| Index: pkg/analyzer/lib/src/dart/analysis/driver.dart |
| diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| index a84d458d3313eb9c5b74f2d59c6ea23cce8730fc..35698f9a36e22ef0660de51e65f42513d2bb535a 100644 |
| --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| @@ -977,6 +977,7 @@ class AnalysisDriverScheduler { |
| * priority first. |
| */ |
| Future<Null> _run() async { |
| + Stopwatch timer = new Stopwatch()..start(); |
| PerformanceLogSection analysisSection; |
| while (true) { |
| // Pump the event queue to allow IO and other asynchronous data |
| @@ -988,7 +989,14 @@ class AnalysisDriverScheduler { |
| // analysis or other data processing tasks are starving. Ideally we |
| // would need to be able to set priority of (continuous) asynchronous |
| // tasks. |
| - await _pumpEventQueue(128); |
| + // |
| + // Relinquishing execution flow and running event loop after every task |
| + // has too much overhead. Instead we use a fixed length of time, so we |
| + // can spend less time overall and still respond quick enough. |
| + if (timer.elapsedMilliseconds > 2) { |
|
Brian Wilkerson
2016/12/01 14:36:38
I think it would be a good thing to define some co
scheglov
2016/12/01 16:55:06
Done.
|
| + await _pumpEventQueue(128); |
| + timer.reset(); |
| + } |
| await _hasWork.signal; |
| @@ -1266,37 +1274,30 @@ class _FilesReferencingNameTask { |
| _FilesReferencingNameTask(this.driver, this.name); |
| /** |
| - * Perform work for a fixed length of time, and either complete the |
| - * [completer] and return `true` to indicate that the task is done, return |
| - * `false` to indicate that the task should continue to be run. |
| - * |
| - * Relinquishing execution flow and running event loop after every file |
| - * works, but has too much overhead. Instead we use a fixed length of time, |
| - * so we can spend less time overall and keep quick enough response time. |
| + * Perform a single piece of work, and either complete the [completer] and |
| + * return `true` to indicate that the task is done, return `false` to indicate |
| + * that the task should continue to be run. |
| */ |
| Future<bool> perform() async { |
| - Stopwatch timer = new Stopwatch()..start(); |
| - while (timer.elapsedMilliseconds < 5) { |
| - // Prepare files to check. |
| - if (filesToCheck.isEmpty) { |
| - Set<String> newFiles = driver.addedFiles.difference(checkedFiles); |
| - filesToCheck.addAll(newFiles); |
| - } |
| + // Prepare files to check. |
| + if (filesToCheck.isEmpty) { |
| + Set<String> newFiles = driver.addedFiles.difference(checkedFiles); |
| + filesToCheck.addAll(newFiles); |
| + } |
| - // If no more files to check, complete and done. |
| - if (filesToCheck.isEmpty) { |
| - completer.complete(referencingFiles); |
| - return true; |
| - } |
| + // If no more files to check, complete and done. |
| + if (filesToCheck.isEmpty) { |
| + completer.complete(referencingFiles); |
| + return true; |
| + } |
| - // Check the next file. |
| - String path = filesToCheck.removeLast(); |
| - FileState file = driver._fsState.getFileForPath(path); |
| - if (file.referencedNames.contains(name)) { |
| - referencingFiles.add(path); |
| - } |
| - checkedFiles.add(path); |
| + // Check the next file. |
| + String path = filesToCheck.removeLast(); |
| + FileState file = driver._fsState.getFileForPath(path); |
| + if (file.referencedNames.contains(name)) { |
| + referencingFiles.add(path); |
| } |
| + checkedFiles.add(path); |
| // We're not done yet. |
| return false; |