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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.cc

Issue 215553002: Report some PNaCl UMA earlier, instead of in one chunk at the end. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
11 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" 11 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h"
12 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h" 12 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h"
13 #include "ppapi/native_client/src/trusted/plugin/srpc_params.h" 13 #include "ppapi/native_client/src/trusted/plugin/srpc_params.h"
14 #include "ppapi/native_client/src/trusted/plugin/temporary_file.h" 14 #include "ppapi/native_client/src/trusted/plugin/temporary_file.h"
15 #include "ppapi/native_client/src/trusted/plugin/utility.h" 15 #include "ppapi/native_client/src/trusted/plugin/utility.h"
16 16
17 namespace plugin { 17 namespace plugin {
18 18
19 PnaclTranslateThread::PnaclTranslateThread() : llc_subprocess_active_(false), 19 PnaclTranslateThread::PnaclTranslateThread() : llc_subprocess_active_(false),
20 ld_subprocess_active_(false), 20 ld_subprocess_active_(false),
21 done_(false), 21 done_(false),
22 time_stats_(), 22 compile_time_(0),
23 manifest_(NULL), 23 manifest_(NULL),
24 obj_files_(NULL), 24 obj_files_(NULL),
25 nexe_file_(NULL), 25 nexe_file_(NULL),
26 coordinator_error_info_(NULL), 26 coordinator_error_info_(NULL),
27 resources_(NULL), 27 resources_(NULL),
28 coordinator_(NULL), 28 coordinator_(NULL),
29 plugin_(NULL) { 29 plugin_(NULL) {
30 NaClXMutexCtor(&subprocess_mu_); 30 NaClXMutexCtor(&subprocess_mu_);
31 NaClXMutexCtor(&cond_mu_); 31 NaClXMutexCtor(&cond_mu_);
32 NaClXCondVarCtor(&buffer_cond_); 32 NaClXCondVarCtor(&buffer_cond_);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 SrpcParams params; 142 SrpcParams params;
143 std::vector<nacl::DescWrapper*> llc_out_files; 143 std::vector<nacl::DescWrapper*> llc_out_files;
144 size_t i; 144 size_t i;
145 for (i = 0; i < obj_files_->size(); i++) { 145 for (i = 0; i < obj_files_->size(); i++) {
146 llc_out_files.push_back((*obj_files_)[i]->write_wrapper()); 146 llc_out_files.push_back((*obj_files_)[i]->write_wrapper());
147 } 147 }
148 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) { 148 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) {
149 llc_out_files.push_back(invalid_desc_wrapper_); 149 llc_out_files.push_back(invalid_desc_wrapper_);
150 } 150 }
151 151
152 pp::Core* core = pp::Module::Get()->core();
152 { 153 {
153 nacl::MutexLocker ml(&subprocess_mu_); 154 nacl::MutexLocker ml(&subprocess_mu_);
154 int64_t llc_start_time = NaClGetTimeOfDayMicroseconds(); 155 int64_t llc_start_time = NaClGetTimeOfDayMicroseconds();
155 llc_subprocess_.reset( 156 llc_subprocess_.reset(
156 StartSubprocess(resources_->GetLlcUrl(), manifest_, &error_info)); 157 StartSubprocess(resources_->GetLlcUrl(), manifest_, &error_info));
157 if (llc_subprocess_ == NULL) { 158 if (llc_subprocess_ == NULL) {
158 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP, 159 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_SETUP,
159 "Compile process could not be created: " + 160 "Compile process could not be created: " +
160 error_info.message()); 161 error_info.message());
161 return; 162 return;
162 } 163 }
163 llc_subprocess_active_ = true; 164 llc_subprocess_active_ = true;
164 time_stats_.pnacl_llc_load_time = 165 core->CallOnMainThread(0,
165 (NaClGetTimeOfDayMicroseconds() - llc_start_time); 166 coordinator_->GetUMATimeCallback(
167 "NaCl.Perf.PNaClLoadTime.LoadCompiler",
168 NaClGetTimeOfDayMicroseconds() - llc_start_time),
169 PP_OK);
166 // Run LLC. 170 // Run LLC.
167 PluginReverseInterface* llc_reverse = 171 PluginReverseInterface* llc_reverse =
168 llc_subprocess_->service_runtime()->rev_interface(); 172 llc_subprocess_->service_runtime()->rev_interface();
169 for (size_t i = 0; i < obj_files_->size(); i++) { 173 for (size_t i = 0; i < obj_files_->size(); i++) {
170 llc_reverse->AddTempQuotaManagedFile((*obj_files_)[i]->identifier()); 174 llc_reverse->AddTempQuotaManagedFile((*obj_files_)[i]->identifier());
171 } 175 }
172 } 176 }
173 177
174 int64_t compile_start_time = NaClGetTimeOfDayMicroseconds(); 178 int64_t compile_start_time = NaClGetTimeOfDayMicroseconds();
175 bool init_success; 179 bool init_success;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // The error message is only present if the error was returned from llc 218 // The error message is only present if the error was returned from llc
215 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, 219 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL,
216 nacl::string("Stream init failed: ") + 220 nacl::string("Stream init failed: ") +
217 nacl::string(params.outs()[0]->arrays.str)); 221 nacl::string(params.outs()[0]->arrays.str));
218 } else { 222 } else {
219 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, 223 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL,
220 "Stream init internal error"); 224 "Stream init internal error");
221 } 225 }
222 return; 226 return;
223 } 227 }
224
225 PLUGIN_PRINTF(("PnaclCoordinator: StreamInit successful\n")); 228 PLUGIN_PRINTF(("PnaclCoordinator: StreamInit successful\n"));
226 pp::Core* core = pp::Module::Get()->core();
227 229
228 // llc process is started. 230 // llc process is started.
229 while(!done_ || data_buffers_.size() > 0) { 231 while(!done_ || data_buffers_.size() > 0) {
230 NaClXMutexLock(&cond_mu_); 232 NaClXMutexLock(&cond_mu_);
231 while(!done_ && data_buffers_.size() == 0) { 233 while(!done_ && data_buffers_.size() == 0) {
232 NaClXCondVarWait(&buffer_cond_, &cond_mu_); 234 NaClXCondVarWait(&buffer_cond_, &cond_mu_);
233 } 235 }
234 PLUGIN_PRINTF(("PnaclTranslateThread awake (done=%d, size=%" NACL_PRIuS 236 PLUGIN_PRINTF(("PnaclTranslateThread awake (done=%d, size=%" NACL_PRIuS
235 ")\n", 237 ")\n",
236 done_, data_buffers_.size())); 238 done_, data_buffers_.size()));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 NACL_SRPC_RESULT_APP_ERROR) { 278 NACL_SRPC_RESULT_APP_ERROR) {
277 // The error string is only present if the error was sent back from llc. 279 // The error string is only present if the error was sent back from llc.
278 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, 280 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL,
279 params.outs()[3]->arrays.str); 281 params.outs()[3]->arrays.str);
280 } else { 282 } else {
281 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL, 283 TranslateFailed(PP_NACL_ERROR_PNACL_LLC_INTERNAL,
282 "Compile StreamEnd internal error"); 284 "Compile StreamEnd internal error");
283 } 285 }
284 return; 286 return;
285 } 287 }
286 time_stats_.pnacl_compile_time = 288 compile_time_ = NaClGetTimeOfDayMicroseconds() - compile_start_time;
287 (NaClGetTimeOfDayMicroseconds() - compile_start_time); 289 core->CallOnMainThread(0,
290 coordinator_->GetUMATimeCallback(
291 "NaCl.Perf.PNaClLoadTime.CompileTime",
292 compile_time_),
293 PP_OK);
288 294
289 // Shut down the llc subprocess. 295 // Shut down the llc subprocess.
290 NaClXMutexLock(&subprocess_mu_); 296 NaClXMutexLock(&subprocess_mu_);
291 llc_subprocess_active_ = false; 297 llc_subprocess_active_ = false;
292 llc_subprocess_.reset(NULL); 298 llc_subprocess_.reset(NULL);
293 NaClXMutexUnlock(&subprocess_mu_); 299 NaClXMutexUnlock(&subprocess_mu_);
294 300
295 if(!RunLdSubprocess()) { 301 if(!RunLdSubprocess()) {
296 return; 302 return;
297 } 303 }
(...skipping 13 matching lines...) Expand all
311 "Link process could not reset object file"); 317 "Link process could not reset object file");
312 return false; 318 return false;
313 } 319 }
314 ld_in_files.push_back((*obj_files_)[i]->read_wrapper()); 320 ld_in_files.push_back((*obj_files_)[i]->read_wrapper());
315 } 321 }
316 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) { 322 for (; i < PnaclCoordinator::kMaxTranslatorObjectFiles; i++) {
317 ld_in_files.push_back(invalid_desc_wrapper_); 323 ld_in_files.push_back(invalid_desc_wrapper_);
318 } 324 }
319 325
320 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper(); 326 nacl::DescWrapper* ld_out_file = nexe_file_->write_wrapper();
321 327 pp::Core* core = pp::Module::Get()->core();
322 { 328 {
323 // Create LD process 329 // Create LD process
324 nacl::MutexLocker ml(&subprocess_mu_); 330 nacl::MutexLocker ml(&subprocess_mu_);
325 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds(); 331 int64_t ld_start_time = NaClGetTimeOfDayMicroseconds();
326 ld_subprocess_.reset( 332 ld_subprocess_.reset(
327 StartSubprocess(resources_->GetLdUrl(), manifest_, &error_info)); 333 StartSubprocess(resources_->GetLdUrl(), manifest_, &error_info));
328 if (ld_subprocess_ == NULL) { 334 if (ld_subprocess_ == NULL) {
329 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP, 335 TranslateFailed(PP_NACL_ERROR_PNACL_LD_SETUP,
330 "Link process could not be created: " + 336 "Link process could not be created: " +
331 error_info.message()); 337 error_info.message());
332 return false; 338 return false;
333 } 339 }
334 ld_subprocess_active_ = true; 340 ld_subprocess_active_ = true;
335 time_stats_.pnacl_ld_load_time = 341 core->CallOnMainThread(0,
336 (NaClGetTimeOfDayMicroseconds() - ld_start_time); 342 coordinator_->GetUMATimeCallback(
343 "NaCl.Perf.PNaClLoadTime.LoadLinker",
344 NaClGetTimeOfDayMicroseconds() - ld_start_time),
345 PP_OK);
337 PluginReverseInterface* ld_reverse = 346 PluginReverseInterface* ld_reverse =
338 ld_subprocess_->service_runtime()->rev_interface(); 347 ld_subprocess_->service_runtime()->rev_interface();
339 ld_reverse->AddTempQuotaManagedFile(nexe_file_->identifier()); 348 ld_reverse->AddTempQuotaManagedFile(nexe_file_->identifier());
340 } 349 }
341 350
342 int64_t link_start_time = NaClGetTimeOfDayMicroseconds(); 351 int64_t link_start_time = NaClGetTimeOfDayMicroseconds();
343 // Run LD. 352 // Run LD.
344 bool success = ld_subprocess_->InvokeSrpcMethod( 353 bool success = ld_subprocess_->InvokeSrpcMethod(
345 "RunWithSplit", 354 "RunWithSplit",
346 "ihhhhhhhhhhhhhhhhh", 355 "ihhhhhhhhhhhhhhhhh",
(...skipping 14 matching lines...) Expand all
361 ld_in_files[12]->desc(), 370 ld_in_files[12]->desc(),
362 ld_in_files[13]->desc(), 371 ld_in_files[13]->desc(),
363 ld_in_files[14]->desc(), 372 ld_in_files[14]->desc(),
364 ld_in_files[15]->desc(), 373 ld_in_files[15]->desc(),
365 ld_out_file->desc()); 374 ld_out_file->desc());
366 if (!success) { 375 if (!success) {
367 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL, 376 TranslateFailed(PP_NACL_ERROR_PNACL_LD_INTERNAL,
368 "link failed."); 377 "link failed.");
369 return false; 378 return false;
370 } 379 }
371 time_stats_.pnacl_link_time = 380 core->CallOnMainThread(0,
372 NaClGetTimeOfDayMicroseconds() - link_start_time; 381 coordinator_->GetUMATimeCallback(
382 "NaCl.Perf.PNaClLoadTime.LinkTime",
383 NaClGetTimeOfDayMicroseconds() - link_start_time),
384 PP_OK);
373 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n", 385 PLUGIN_PRINTF(("PnaclCoordinator: link (translator=%p) succeeded\n",
374 this)); 386 this));
375 // Shut down the ld subprocess. 387 // Shut down the ld subprocess.
376 NaClXMutexLock(&subprocess_mu_); 388 NaClXMutexLock(&subprocess_mu_);
377 ld_subprocess_active_ = false; 389 ld_subprocess_active_ = false;
378 ld_subprocess_.reset(NULL); 390 ld_subprocess_.reset(NULL);
379 NaClXMutexUnlock(&subprocess_mu_); 391 NaClXMutexUnlock(&subprocess_mu_);
380 return true; 392 return true;
381 } 393 }
382 394
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 AbortSubprocesses(); 432 AbortSubprocesses();
421 if (translate_thread_ != NULL) 433 if (translate_thread_ != NULL)
422 NaClThreadJoin(translate_thread_.get()); 434 NaClThreadJoin(translate_thread_.get());
423 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n")); 435 PLUGIN_PRINTF(("~PnaclTranslateThread joined\n"));
424 NaClCondVarDtor(&buffer_cond_); 436 NaClCondVarDtor(&buffer_cond_);
425 NaClMutexDtor(&cond_mu_); 437 NaClMutexDtor(&cond_mu_);
426 NaClMutexDtor(&subprocess_mu_); 438 NaClMutexDtor(&subprocess_mu_);
427 } 439 }
428 440
429 } // namespace plugin 441 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698