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

Side by Side Diff: pkg/analysis_server/lib/src/domain_completion.dart

Issue 889583004: fix race condition when recording computeCache performance (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/get_handler.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library domain.completion; 5 library domain.completion;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/constants.dart'; 10 import 'package:analysis_server/src/constants.dart';
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 new List<CompletionPerformance>(); 56 new List<CompletionPerformance>();
57 57
58 /** 58 /**
59 * The maximum number of performance measurements to keep. 59 * The maximum number of performance measurements to keep.
60 */ 60 */
61 static const int performanceListMaxLength = 50; 61 static const int performanceListMaxLength = 50;
62 62
63 /** 63 /**
64 * Performance for the last priority change event. 64 * Performance for the last priority change event.
65 */ 65 */
66 CompletionPerformance priorityChangedPerformance; 66 CompletionPerformance computeCachePerformance;
67 67
68 /** 68 /**
69 * Initialize a new request handler for the given [server]. 69 * Initialize a new request handler for the given [server].
70 */ 70 */
71 CompletionDomainHandler(this.server) { 71 CompletionDomainHandler(this.server) {
72 server.onContextsChanged.listen(contextsChanged); 72 server.onContextsChanged.listen(contextsChanged);
73 server.onPriorityChange.listen(priorityChanged); 73 server.onPriorityChange.listen(priorityChanged);
74 } 74 }
75 75
76 /** 76 /**
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 return null; 130 return null;
131 } 131 }
132 132
133 /** 133 /**
134 * If the set the priority files has changed, then pre-cache completion 134 * If the set the priority files has changed, then pre-cache completion
135 * information related to the first priority file. 135 * information related to the first priority file.
136 */ 136 */
137 void priorityChanged(PriorityChangeEvent event) { 137 void priorityChanged(PriorityChangeEvent event) {
138 Source source = event.firstSource; 138 Source source = event.firstSource;
139 priorityChangedPerformance = new CompletionPerformance(); 139 CompletionPerformance performance = new CompletionPerformance();
140 priorityChangedPerformance.source = source; 140 computeCachePerformance = performance;
141 if (source != null) { 141 if (source == null) {
142 AnalysisContext context = server.getAnalysisContextForSource(source); 142 performance.complete('priorityChanged caching: no source');
143 if (context != null) { 143 return;
144 String computeTag = 'computeCache';
145 priorityChangedPerformance.logStartTime(computeTag);
146 CompletionManager manager = completionManagerFor(context, source);
147 manager.computeCache().then((bool success) {
148 priorityChangedPerformance.logElapseTime(computeTag);
149 priorityChangedPerformance.complete(
150 'priorityChanged caching: $success');
151 });
152 return;
153 }
154 } 144 }
155 priorityChangedPerformance.complete(); 145 performance.source = source;
146 AnalysisContext context = server.getAnalysisContextForSource(source);
147 if (context != null) {
148 String computeTag = 'computeCache';
149 performance.logStartTime(computeTag);
150 CompletionManager manager = completionManagerFor(context, source);
151 manager.computeCache().then((bool success) {
152 performance.logElapseTime(computeTag);
153 performance.complete('priorityChanged caching: $success');
154 });
155 }
156 } 156 }
157 157
158 /** 158 /**
159 * Process a `completion.getSuggestions` request. 159 * Process a `completion.getSuggestions` request.
160 */ 160 */
161 Response processRequest(Request request) { 161 Response processRequest(Request request) {
162 performance = new CompletionPerformance(); 162 performance = new CompletionPerformance();
163 // extract params 163 // extract params
164 CompletionGetSuggestionsParams params = 164 CompletionGetSuggestionsParams params =
165 new CompletionGetSuggestionsParams.fromRequest(request); 165 new CompletionGetSuggestionsParams.fromRequest(request);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 completionId).toResponse(request.id); 197 completionId).toResponse(request.id);
198 } 198 }
199 199
200 /** 200 /**
201 * If tracking code completion performance over time, then 201 * If tracking code completion performance over time, then
202 * record addition information about the request in the performance record. 202 * record addition information about the request in the performance record.
203 */ 203 */
204 void recordRequest(CompletionPerformance performance, AnalysisContext context, 204 void recordRequest(CompletionPerformance performance, AnalysisContext context,
205 Source source, int offset) { 205 Source source, int offset) {
206 performance.source = source; 206 performance.source = source;
207 if (priorityChangedPerformance != null &&
208 priorityChangedPerformance.source != source) {
209 priorityChangedPerformance = null;
210 }
211 if (performanceListMaxLength == 0 || context == null || source == null) { 207 if (performanceListMaxLength == 0 || context == null || source == null) {
212 return; 208 return;
213 } 209 }
214 TimestampedData<String> data = context.getContents(source); 210 TimestampedData<String> data = context.getContents(source);
215 if (data == null) { 211 if (data == null) {
216 return; 212 return;
217 } 213 }
218 performance.setContentsAndOffset(data.data, offset); 214 performance.setContentsAndOffset(data.data, offset);
219 while (performanceList.length >= performanceListMaxLength) { 215 while (performanceList.length >= performanceListMaxLength) {
220 performanceList.removeAt(0); 216 performanceList.removeAt(0);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (_sourcesChangedSubscription != null) { 262 if (_sourcesChangedSubscription != null) {
267 _sourcesChangedSubscription.cancel(); 263 _sourcesChangedSubscription.cancel();
268 _sourcesChangedSubscription = null; 264 _sourcesChangedSubscription = null;
269 } 265 }
270 if (_manager != null) { 266 if (_manager != null) {
271 _manager.dispose(); 267 _manager.dispose();
272 _manager = null; 268 _manager = null;
273 } 269 }
274 } 270 }
275 } 271 }
OLDNEW
« 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