| Index: ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| index d67b99147604412da3e2eba0d920a997045faf90..0f9b9ed22184f8e759d18ef582a702bb037d794b 100644
|
| --- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| +++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
|
| @@ -121,85 +121,56 @@ const int32_t kKBPSMin = 1;
|
| const int32_t kKBPSMax = 30*1000; // max of 30 MB / sec.
|
| const uint32_t kKBPSBuckets = 100;
|
|
|
| -const PPB_UMA_Private* uma_interface = NULL;
|
| -
|
| -const PPB_UMA_Private* GetUMAInterface() {
|
| - if (uma_interface != NULL) {
|
| - return uma_interface;
|
| - }
|
| - pp::Module *module = pp::Module::Get();
|
| - DCHECK(module);
|
| - uma_interface = static_cast<const PPB_UMA_Private*>(
|
| - module->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE));
|
| - return uma_interface;
|
| -}
|
| -
|
| -void HistogramTime(const std::string& name, int64_t ms) {
|
| +void HistogramTime(const pp::UMAPrivate& uma,
|
| + const std::string& name, int64_t ms) {
|
| if (ms < 0) return;
|
| -
|
| - const PPB_UMA_Private* ptr = GetUMAInterface();
|
| - if (ptr == NULL) return;
|
| -
|
| - ptr->HistogramCustomTimes(pp::Var(name).pp_var(),
|
| - ms,
|
| - kTimeLargeMin, kTimeLargeMax,
|
| - kTimeLargeBuckets);
|
| + uma.HistogramCustomTimes(name,
|
| + ms,
|
| + kTimeLargeMin, kTimeLargeMax,
|
| + kTimeLargeBuckets);
|
| }
|
|
|
| -void HistogramSizeKB(const std::string& name, int32_t kb) {
|
| +void HistogramSizeKB(const pp::UMAPrivate& uma,
|
| + const std::string& name, int32_t kb) {
|
| if (kb < 0) return;
|
| -
|
| - const PPB_UMA_Private* ptr = GetUMAInterface();
|
| - if (ptr == NULL) return;
|
| -
|
| - ptr->HistogramCustomCounts(pp::Var(name).pp_var(),
|
| - kb,
|
| - kSizeKBMin, kSizeKBMax,
|
| - kSizeKBBuckets);
|
| + uma.HistogramCustomCounts(name,
|
| + kb,
|
| + kSizeKBMin, kSizeKBMax,
|
| + kSizeKBBuckets);
|
| }
|
|
|
| -void HistogramRatio(const std::string& name, int64_t a, int64_t b) {
|
| +void HistogramRatio(const pp::UMAPrivate& uma,
|
| + const std::string& name, int64_t a, int64_t b) {
|
| if (a < 0 || b <= 0) return;
|
| -
|
| - const PPB_UMA_Private* ptr = GetUMAInterface();
|
| - if (ptr == NULL) return;
|
| -
|
| - ptr->HistogramCustomCounts(pp::Var(name).pp_var(),
|
| - 100 * a / b,
|
| - kRatioMin, kRatioMax,
|
| - kRatioBuckets);
|
| + uma.HistogramCustomCounts(name,
|
| + 100 * a / b,
|
| + kRatioMin, kRatioMax,
|
| + kRatioBuckets);
|
| }
|
|
|
| -void HistogramKBPerSec(const std::string& name, double kb, double s) {
|
| +void HistogramKBPerSec(const pp::UMAPrivate& uma,
|
| + const std::string& name, double kb, double s) {
|
| if (kb < 0.0 || s <= 0.0) return;
|
| -
|
| - const PPB_UMA_Private* ptr = GetUMAInterface();
|
| - if (ptr == NULL) return;
|
| -
|
| - ptr->HistogramCustomCounts(pp::Var(name).pp_var(),
|
| - static_cast<int64_t>(kb / s),
|
| - kKBPSMin, kKBPSMax,
|
| - kKBPSBuckets);
|
| + uma.HistogramCustomCounts(name,
|
| + static_cast<int64_t>(kb / s),
|
| + kKBPSMin, kKBPSMax,
|
| + kKBPSBuckets);
|
| }
|
|
|
| -void HistogramEnumerateTranslationCache(bool hit) {
|
| - const PPB_UMA_Private* ptr = GetUMAInterface();
|
| - if (ptr == NULL) return;
|
| - ptr->HistogramEnumeration(pp::Var("NaCl.Perf.PNaClCache.IsHit").pp_var(),
|
| - hit, 2);
|
| +void HistogramEnumerateTranslationCache(const pp::UMAPrivate& uma, bool hit) {
|
| + uma.HistogramEnumeration("NaCl.Perf.PNaClCache.IsHit",
|
| + hit, 2);
|
| }
|
|
|
| // Opt level is expected to be 0 to 3. Treating 4 as unknown.
|
| const int8_t kOptUnknown = 4;
|
|
|
| -void HistogramOptLevel(int8_t opt_level) {
|
| - const PPB_UMA_Private* ptr = GetUMAInterface();
|
| - if (ptr == NULL) return;
|
| +void HistogramOptLevel(const pp::UMAPrivate& uma, int8_t opt_level) {
|
| if (opt_level < 0 || opt_level > 3) {
|
| opt_level = kOptUnknown;
|
| }
|
| - ptr->HistogramEnumeration(pp::Var("NaCl.Options.PNaCl.OptLevel").pp_var(),
|
| - opt_level, kOptUnknown+1);
|
| + uma.HistogramEnumeration("NaCl.Options.PNaCl.OptLevel",
|
| + opt_level, kOptUnknown+1);
|
| }
|
|
|
| } // namespace
|
| @@ -352,20 +323,22 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) {
|
| }
|
|
|
| // If there are no errors, report stats from this thread (the main thread).
|
| - HistogramOptLevel(pnacl_options_.opt_level());
|
| + HistogramOptLevel(plugin_->uma_interface(), pnacl_options_.opt_level());
|
| const plugin::PnaclTimeStats& time_stats = translate_thread_->GetTimeStats();
|
| - HistogramTime("NaCl.Perf.PNaClLoadTime.LoadCompiler",
|
| + HistogramTime(plugin_->uma_interface(),
|
| + "NaCl.Perf.PNaClLoadTime.LoadCompiler",
|
| time_stats.pnacl_llc_load_time / NACL_MICROS_PER_MILLI);
|
| - HistogramTime("NaCl.Perf.PNaClLoadTime.CompileTime",
|
| + HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.CompileTime",
|
| time_stats.pnacl_compile_time / NACL_MICROS_PER_MILLI);
|
| - HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.CompileKBPerSec",
|
| + HistogramKBPerSec(plugin_->uma_interface(),
|
| + "NaCl.Perf.PNaClLoadTime.CompileKBPerSec",
|
| pexe_size_ / 1024.0,
|
| time_stats.pnacl_compile_time / 1000000.0);
|
| - HistogramTime("NaCl.Perf.PNaClLoadTime.LoadLinker",
|
| + HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.LoadLinker",
|
| time_stats.pnacl_ld_load_time / NACL_MICROS_PER_MILLI);
|
| - HistogramTime("NaCl.Perf.PNaClLoadTime.LinkTime",
|
| + HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.LinkTime",
|
| time_stats.pnacl_link_time / NACL_MICROS_PER_MILLI);
|
| - HistogramSizeKB("NaCl.Perf.Size.Pexe",
|
| + HistogramSizeKB(plugin_->uma_interface(), "NaCl.Perf.Size.Pexe",
|
| static_cast<int64_t>(pexe_size_ / 1024));
|
|
|
| struct nacl_abi_stat stbuf;
|
| @@ -376,15 +349,19 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) {
|
| PLUGIN_PRINTF(("PnaclCoordinator::TranslateFinished can't stat nexe.\n"));
|
| } else {
|
| size_t nexe_size = stbuf.nacl_abi_st_size;
|
| - HistogramSizeKB("NaCl.Perf.Size.PNaClTranslatedNexe",
|
| + HistogramSizeKB(plugin_->uma_interface(),
|
| + "NaCl.Perf.Size.PNaClTranslatedNexe",
|
| static_cast<int64_t>(nexe_size / 1024));
|
| - HistogramRatio("NaCl.Perf.Size.PexeNexeSizePct", pexe_size_, nexe_size);
|
| + HistogramRatio(plugin_->uma_interface(),
|
| + "NaCl.Perf.Size.PexeNexeSizePct", pexe_size_, nexe_size);
|
| }
|
|
|
| int64_t total_time = NaClGetTimeOfDayMicroseconds() - pnacl_init_time_;
|
| - HistogramTime("NaCl.Perf.PNaClLoadTime.TotalUncachedTime",
|
| + HistogramTime(plugin_->uma_interface(),
|
| + "NaCl.Perf.PNaClLoadTime.TotalUncachedTime",
|
| total_time / NACL_MICROS_PER_MILLI);
|
| - HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec",
|
| + HistogramKBPerSec(plugin_->uma_interface(),
|
| + "NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec",
|
| pexe_size_ / 1024.0,
|
| total_time / 1000000.0);
|
|
|
| @@ -547,7 +524,7 @@ void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) {
|
| "PnaclCoordinator: Got bad temp file handle from GetNexeFd"));
|
| return;
|
| }
|
| - HistogramEnumerateTranslationCache(is_cache_hit_);
|
| + HistogramEnumerateTranslationCache(plugin_->uma_interface(), is_cache_hit_);
|
|
|
| if (is_cache_hit_ == PP_TRUE) {
|
| // Cache hit -- no need to stream the rest of the file.
|
| @@ -597,7 +574,8 @@ void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) {
|
| translate_thread_->AbortSubprocesses();
|
| } else {
|
| // Compare download completion pct (100% now), to compile completion pct.
|
| - HistogramRatio("NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded",
|
| + HistogramRatio(plugin_->uma_interface(),
|
| + "NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded",
|
| pexe_bytes_compiled_, pexe_size_);
|
| }
|
| }
|
|
|