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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.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, 9 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
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_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"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 const int32_t kRatioMin = 10; 122 const int32_t kRatioMin = 10;
123 const int32_t kRatioMax = 10*100; // max of 10x difference. 123 const int32_t kRatioMax = 10*100; // max of 10x difference.
124 const uint32_t kRatioBuckets = 100; 124 const uint32_t kRatioBuckets = 100;
125 125
126 const int32_t kKBPSMin = 1; 126 const int32_t kKBPSMin = 1;
127 const int32_t kKBPSMax = 30*1000; // max of 30 MB / sec. 127 const int32_t kKBPSMax = 30*1000; // max of 30 MB / sec.
128 const uint32_t kKBPSBuckets = 100; 128 const uint32_t kKBPSBuckets = 100;
129 129
130 void HistogramTime(pp::UMAPrivate& uma, 130 void HistogramTime(pp::UMAPrivate& uma,
131 const std::string& name, int64_t ms) { 131 const nacl::string& name, int64_t ms) {
132 if (ms < 0) return; 132 if (ms < 0) return;
133 uma.HistogramCustomTimes(name, 133 uma.HistogramCustomTimes(name,
134 ms, 134 ms,
135 kTimeLargeMin, kTimeLargeMax, 135 kTimeLargeMin, kTimeLargeMax,
136 kTimeLargeBuckets); 136 kTimeLargeBuckets);
137 } 137 }
138 138
139 void HistogramSizeKB(pp::UMAPrivate& uma, 139 void HistogramSizeKB(pp::UMAPrivate& uma,
140 const std::string& name, int32_t kb) { 140 const nacl::string& name, int32_t kb) {
141 if (kb < 0) return; 141 if (kb < 0) return;
142 uma.HistogramCustomCounts(name, 142 uma.HistogramCustomCounts(name,
143 kb, 143 kb,
144 kSizeKBMin, kSizeKBMax, 144 kSizeKBMin, kSizeKBMax,
145 kSizeKBBuckets); 145 kSizeKBBuckets);
146 } 146 }
147 147
148 void HistogramRatio(pp::UMAPrivate& uma, 148 void HistogramRatio(pp::UMAPrivate& uma,
149 const std::string& name, int64_t a, int64_t b) { 149 const nacl::string& name, int64_t a, int64_t b) {
150 if (a < 0 || b <= 0) return; 150 if (a < 0 || b <= 0) return;
151 uma.HistogramCustomCounts(name, 151 uma.HistogramCustomCounts(name,
152 100 * a / b, 152 100 * a / b,
153 kRatioMin, kRatioMax, 153 kRatioMin, kRatioMax,
154 kRatioBuckets); 154 kRatioBuckets);
155 } 155 }
156 156
157 void HistogramKBPerSec(pp::UMAPrivate& uma, 157 void HistogramKBPerSec(pp::UMAPrivate& uma,
158 const std::string& name, double kb, double s) { 158 const nacl::string& name, double kb, double s) {
159 if (kb < 0.0 || s <= 0.0) return; 159 if (kb < 0.0 || s <= 0.0) return;
160 uma.HistogramCustomCounts(name, 160 uma.HistogramCustomCounts(name,
161 static_cast<int64_t>(kb / s), 161 static_cast<int64_t>(kb / s),
162 kKBPSMin, kKBPSMax, 162 kKBPSMin, kKBPSMax,
163 kKBPSBuckets); 163 kKBPSBuckets);
164 } 164 }
165 165
166 void HistogramEnumerateTranslationCache(pp::UMAPrivate& uma, bool hit) { 166 void HistogramEnumerateTranslationCache(pp::UMAPrivate& uma, bool hit) {
167 uma.HistogramEnumeration("NaCl.Perf.PNaClCache.IsHit", 167 uma.HistogramEnumeration("NaCl.Perf.PNaClCache.IsHit",
168 hit, 2); 168 hit, 2);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 pexe_bytes_compiled_ = expected_pexe_size_; 332 pexe_bytes_compiled_ = expected_pexe_size_;
333 plugin_->EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS, 333 plugin_->EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS,
334 pexe_url_, 334 pexe_url_,
335 plugin::Plugin::LENGTH_IS_COMPUTABLE, 335 plugin::Plugin::LENGTH_IS_COMPUTABLE,
336 pexe_bytes_compiled_, 336 pexe_bytes_compiled_,
337 expected_pexe_size_); 337 expected_pexe_size_);
338 } 338 }
339 339
340 // If there are no errors, report stats from this thread (the main thread). 340 // If there are no errors, report stats from this thread (the main thread).
341 HistogramOptLevel(plugin_->uma_interface(), pnacl_options_.opt_level()); 341 HistogramOptLevel(plugin_->uma_interface(), pnacl_options_.opt_level());
342 const plugin::PnaclTimeStats& time_stats = translate_thread_->GetTimeStats();
343 HistogramTime(plugin_->uma_interface(),
344 "NaCl.Perf.PNaClLoadTime.LoadCompiler",
345 time_stats.pnacl_llc_load_time / NACL_MICROS_PER_MILLI);
346 HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.CompileTime",
347 time_stats.pnacl_compile_time / NACL_MICROS_PER_MILLI);
348 HistogramKBPerSec(plugin_->uma_interface(), 342 HistogramKBPerSec(plugin_->uma_interface(),
349 "NaCl.Perf.PNaClLoadTime.CompileKBPerSec", 343 "NaCl.Perf.PNaClLoadTime.CompileKBPerSec",
350 pexe_size_ / 1024.0, 344 pexe_size_ / 1024.0,
351 time_stats.pnacl_compile_time / 1000000.0); 345 translate_thread_->GetCompileTime() / 1000000.0);
352 HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.LoadLinker",
353 time_stats.pnacl_ld_load_time / NACL_MICROS_PER_MILLI);
354 HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.LinkTime",
355 time_stats.pnacl_link_time / NACL_MICROS_PER_MILLI);
356 HistogramSizeKB(plugin_->uma_interface(), "NaCl.Perf.Size.Pexe", 346 HistogramSizeKB(plugin_->uma_interface(), "NaCl.Perf.Size.Pexe",
357 static_cast<int64_t>(pexe_size_ / 1024)); 347 static_cast<int64_t>(pexe_size_ / 1024));
358 348
359 struct nacl_abi_stat stbuf; 349 struct nacl_abi_stat stbuf;
360 struct NaClDesc* desc = temp_nexe_file_->read_wrapper()->desc(); 350 struct NaClDesc* desc = temp_nexe_file_->read_wrapper()->desc();
361 int stat_ret; 351 int stat_ret;
362 if (0 != (stat_ret = (*((struct NaClDescVtbl const *) desc->base.vtbl)-> 352 if (0 != (stat_ret = (*((struct NaClDescVtbl const *) desc->base.vtbl)->
363 Fstat)(desc, &stbuf))) { 353 Fstat)(desc, &stbuf))) {
364 PLUGIN_PRINTF(("PnaclCoordinator::TranslateFinished can't stat nexe.\n")); 354 PLUGIN_PRINTF(("PnaclCoordinator::TranslateFinished can't stat nexe.\n"));
365 } else { 355 } else {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 } 604 }
615 } 605 }
616 606
617 StreamCallback PnaclCoordinator::GetCallback() { 607 StreamCallback PnaclCoordinator::GetCallback() {
618 return callback_factory_.NewCallbackWithOutput( 608 return callback_factory_.NewCallbackWithOutput(
619 &PnaclCoordinator::BitcodeStreamGotData); 609 &PnaclCoordinator::BitcodeStreamGotData);
620 } 610 }
621 611
622 void PnaclCoordinator::BitcodeGotCompiled(int32_t pp_error, 612 void PnaclCoordinator::BitcodeGotCompiled(int32_t pp_error,
623 int64_t bytes_compiled) { 613 int64_t bytes_compiled) {
614 DCHECK(pp_error == PP_OK);
624 pexe_bytes_compiled_ += bytes_compiled; 615 pexe_bytes_compiled_ += bytes_compiled;
625 // If we don't know the expected total yet, ask. 616 // If we don't know the expected total yet, ask.
626 if (!ExpectedProgressKnown()) { 617 if (!ExpectedProgressKnown()) {
627 int64_t amount_downloaded; // dummy variable. 618 int64_t amount_downloaded; // dummy variable.
628 streaming_downloader_->GetDownloadProgress(&amount_downloaded, 619 streaming_downloader_->GetDownloadProgress(&amount_downloaded,
629 &expected_pexe_size_); 620 &expected_pexe_size_);
630 } 621 }
631 // Hold off reporting the last few bytes of progress, since we don't know 622 // Hold off reporting the last few bytes of progress, since we don't know
632 // when they are actually completely compiled. "bytes_compiled" only means 623 // when they are actually completely compiled. "bytes_compiled" only means
633 // that bytes were sent to the compiler. 624 // that bytes were sent to the compiler.
(...skipping 13 matching lines...) Expand all
647 expected_pexe_size_); 638 expected_pexe_size_);
648 } 639 }
649 } 640 }
650 641
651 pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback( 642 pp::CompletionCallback PnaclCoordinator::GetCompileProgressCallback(
652 int64_t bytes_compiled) { 643 int64_t bytes_compiled) {
653 return callback_factory_.NewCallback(&PnaclCoordinator::BitcodeGotCompiled, 644 return callback_factory_.NewCallback(&PnaclCoordinator::BitcodeGotCompiled,
654 bytes_compiled); 645 bytes_compiled);
655 } 646 }
656 647
648 void PnaclCoordinator::DoUMATimeMeasure(int32_t pp_error,
649 const nacl::string& event_name,
650 int64_t microsecs) {
651 DCHECK(pp_error == PP_OK);
652 HistogramTime(
653 plugin_->uma_interface(), event_name, microsecs / NACL_MICROS_PER_MILLI);
654 }
655
656 pp::CompletionCallback PnaclCoordinator::GetUMATimeCallback(
657 const nacl::string& event_name, int64_t microsecs) {
658 return callback_factory_.NewCallback(&PnaclCoordinator::DoUMATimeMeasure,
659 event_name,
660 microsecs);
661 }
662
657 void PnaclCoordinator::GetCurrentProgress(int64_t* bytes_loaded, 663 void PnaclCoordinator::GetCurrentProgress(int64_t* bytes_loaded,
658 int64_t* bytes_total) { 664 int64_t* bytes_total) {
659 *bytes_loaded = pexe_bytes_compiled_; 665 *bytes_loaded = pexe_bytes_compiled_;
660 *bytes_total = expected_pexe_size_; 666 *bytes_total = expected_pexe_size_;
661 } 667 }
662 668
663 void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) { 669 void PnaclCoordinator::ObjectFileDidOpen(int32_t pp_error) {
664 PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%" 670 PLUGIN_PRINTF(("PnaclCoordinator::ObjectFileDidOpen (pp_error=%"
665 NACL_PRId32 ")\n", pp_error)); 671 NACL_PRId32 ")\n", pp_error));
666 if (pp_error != PP_OK) { 672 if (pp_error != PP_OK) {
(...skipping 27 matching lines...) Expand all
694 temp_nexe_file_.get(), 700 temp_nexe_file_.get(),
695 invalid_desc_wrapper_.get(), 701 invalid_desc_wrapper_.get(),
696 &error_info_, 702 &error_info_,
697 resources_.get(), 703 resources_.get(),
698 &pnacl_options_, 704 &pnacl_options_,
699 this, 705 this,
700 plugin_); 706 plugin_);
701 } 707 }
702 708
703 } // namespace plugin 709 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698