OLD | NEW |
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_coordinator.h" | 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "native_client/src/include/checked_cast.h" | 10 #include "native_client/src/include/checked_cast.h" |
11 #include "native_client/src/include/portability_io.h" | 11 #include "native_client/src/include/portability_io.h" |
12 #include "native_client/src/shared/platform/nacl_check.h" | 12 #include "native_client/src/shared/platform/nacl_check.h" |
13 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" | 13 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" |
14 | 14 |
15 #include "ppapi/c/pp_bool.h" | 15 #include "ppapi/c/pp_bool.h" |
16 #include "ppapi/c/pp_errors.h" | 16 #include "ppapi/c/pp_errors.h" |
17 #include "ppapi/c/private/ppb_uma_private.h" | 17 #include "ppapi/c/private/ppb_uma_private.h" |
18 | 18 |
19 #include "ppapi/native_client/src/trusted/plugin/plugin.h" | 19 #include "ppapi/native_client/src/trusted/plugin/plugin.h" |
20 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" | 20 #include "ppapi/native_client/src/trusted/plugin/plugin_error.h" |
21 #include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" | 21 #include "ppapi/native_client/src/trusted/plugin/pnacl_translate_thread.h" |
22 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" | 22 #include "ppapi/native_client/src/trusted/plugin/service_runtime.h" |
23 #include "ppapi/native_client/src/trusted/plugin/temporary_file.h" | 23 #include "ppapi/native_client/src/trusted/plugin/temporary_file.h" |
24 | 24 |
25 namespace plugin { | 25 namespace plugin { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 // Assume translation time metrics *can be* large. | |
30 // Up to 12 minutes. | |
31 const int64_t kTimeLargeMin = 10; // in ms | |
32 const int64_t kTimeLargeMax = 720000; // in ms | |
33 const uint32_t kTimeLargeBuckets = 100; | |
34 | |
35 const int32_t kSizeKBMin = 1; | 29 const int32_t kSizeKBMin = 1; |
36 const int32_t kSizeKBMax = 512*1024; // very large .pexe / .nexe. | 30 const int32_t kSizeKBMax = 512*1024; // very large .pexe / .nexe. |
37 const uint32_t kSizeKBBuckets = 100; | 31 const uint32_t kSizeKBBuckets = 100; |
38 | 32 |
39 const int32_t kRatioMin = 10; | 33 const int32_t kRatioMin = 10; |
40 const int32_t kRatioMax = 10*100; // max of 10x difference. | 34 const int32_t kRatioMax = 10*100; // max of 10x difference. |
41 const uint32_t kRatioBuckets = 100; | 35 const uint32_t kRatioBuckets = 100; |
42 | 36 |
43 void HistogramTime(pp::UMAPrivate& uma, | |
44 const nacl::string& name, int64_t ms) { | |
45 if (ms < 0) return; | |
46 uma.HistogramCustomTimes(name, | |
47 ms, | |
48 kTimeLargeMin, kTimeLargeMax, | |
49 kTimeLargeBuckets); | |
50 } | |
51 | |
52 void HistogramSizeKB(pp::UMAPrivate& uma, | 37 void HistogramSizeKB(pp::UMAPrivate& uma, |
53 const nacl::string& name, int32_t kb) { | 38 const nacl::string& name, int32_t kb) { |
54 if (kb < 0) return; | 39 if (kb < 0) return; |
55 uma.HistogramCustomCounts(name, | 40 uma.HistogramCustomCounts(name, |
56 kb, | 41 kb, |
57 kSizeKBMin, kSizeKBMax, | 42 kSizeKBMin, kSizeKBMax, |
58 kSizeKBBuckets); | 43 kSizeKBBuckets); |
59 } | 44 } |
60 | 45 |
61 void HistogramRatio(pp::UMAPrivate& uma, | 46 void HistogramRatio(pp::UMAPrivate& uma, |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 expected_pexe_size_); | 508 expected_pexe_size_); |
524 } | 509 } |
525 } | 510 } |
526 | 511 |
527 pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback( | 512 pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback( |
528 int64_t bytes_compiled) { | 513 int64_t bytes_compiled) { |
529 return callback_factory_.NewCallback(&PnaclCoordinator::BitcodeGotCompiled, | 514 return callback_factory_.NewCallback(&PnaclCoordinator::BitcodeGotCompiled, |
530 bytes_compiled); | 515 bytes_compiled); |
531 } | 516 } |
532 | 517 |
533 void PnaclCoordinator::DoUMATimeMeasure(int32_t pp_error, | |
534 const nacl::string& event_name, | |
535 int64_t microsecs) { | |
536 DCHECK(pp_error == PP_OK); | |
537 HistogramTime( | |
538 plugin_->uma_interface(), event_name, microsecs / NACL_MICROS_PER_MILLI); | |
539 } | |
540 | |
541 pp::CompletionCallback PnaclCoordinator::GetUMATimeCallback( | |
542 const nacl::string& event_name, int64_t microsecs) { | |
543 return callback_factory_.NewCallback(&PnaclCoordinator::DoUMATimeMeasure, | |
544 event_name, | |
545 microsecs); | |
546 } | |
547 | |
548 void PnaclCoordinator::GetCurrentProgress(int64_t* bytes_loaded, | 518 void PnaclCoordinator::GetCurrentProgress(int64_t* bytes_loaded, |
549 int64_t* bytes_total) { | 519 int64_t* bytes_total) { |
550 *bytes_loaded = pexe_bytes_compiled_; | 520 *bytes_loaded = pexe_bytes_compiled_; |
551 *bytes_total = expected_pexe_size_; | 521 *bytes_total = expected_pexe_size_; |
552 } | 522 } |
553 | 523 |
554 void PnaclCoordinator::RunTranslate(int32_t pp_error) { | 524 void PnaclCoordinator::RunTranslate(int32_t pp_error) { |
555 PLUGIN_PRINTF(("PnaclCoordinator::RunTranslate (pp_error=%" | 525 PLUGIN_PRINTF(("PnaclCoordinator::RunTranslate (pp_error=%" |
556 NACL_PRId32 ")\n", pp_error)); | 526 NACL_PRId32 ")\n", pp_error)); |
557 // Invoke llc followed by ld off the main thread. This allows use of | 527 // Invoke llc followed by ld off the main thread. This allows use of |
558 // blocking RPCs that would otherwise block the JavaScript main thread. | 528 // blocking RPCs that would otherwise block the JavaScript main thread. |
559 pp::CompletionCallback report_translate_finished = | 529 pp::CompletionCallback report_translate_finished = |
560 callback_factory_.NewCallback(&PnaclCoordinator::TranslateFinished); | 530 callback_factory_.NewCallback(&PnaclCoordinator::TranslateFinished); |
561 | 531 |
562 CHECK(translate_thread_ != NULL); | 532 CHECK(translate_thread_ != NULL); |
563 translate_thread_->RunTranslate(report_translate_finished, | 533 translate_thread_->RunTranslate(report_translate_finished, |
564 &obj_files_, | 534 &obj_files_, |
565 temp_nexe_file_.get(), | 535 temp_nexe_file_.get(), |
566 invalid_desc_wrapper_.get(), | 536 invalid_desc_wrapper_.get(), |
567 &error_info_, | 537 &error_info_, |
568 resources_.get(), | 538 resources_.get(), |
569 &pnacl_options_, | 539 &pnacl_options_, |
570 architecture_attributes_, | 540 architecture_attributes_, |
571 this, | 541 this, |
572 plugin_); | 542 plugin_); |
573 } | 543 } |
574 | 544 |
575 } // namespace plugin | 545 } // namespace plugin |
OLD | NEW |