From 4ad500d878f93c781b98208be3c69ea0119c0567 Mon Sep 17 00:00:00 2001 From: Aaron Vaage Date: Mon, 12 Dec 2016 15:05:07 -0800 Subject: [PATCH] [ OEMCrypto Profiler ] Removed Call Table This is a merge of go/wvgerrit/22627 The call table was meant to be a long-term way to track the performance of all OEMCrypto function calls. This feature does not get used. Apps that call into the profiler can generate this from the history. This change was designed to go into Android O (go/wvgerrit/22503) but since the Call Table is causing problems on specific chip sets its being removed in NYC MR2. Bug: 33550032 Bug: 33459261 Change-Id: I2af417a32452e7d0d0a1ada8794efd849c497dc8 --- libwvdrmengine/cdm/Android.mk | 1 - .../cdm/profiler/include/call_table.h | 49 --------- .../cdm/profiler/include/profiler.h | 3 - .../cdm/profiler/src/call_table.cpp | 103 ------------------ .../cdm/profiler/src/profiled_scope.cpp | 1 - libwvdrmengine/cdm/profiler/src/profiler.cpp | 5 - libwvdrmengine/mediadrm/src/WVDrmPlugin.cpp | 18 --- 7 files changed, 180 deletions(-) delete mode 100644 libwvdrmengine/cdm/profiler/include/call_table.h delete mode 100644 libwvdrmengine/cdm/profiler/src/call_table.cpp diff --git a/libwvdrmengine/cdm/Android.mk b/libwvdrmengine/cdm/Android.mk index 5645d69e..d61aeb61 100644 --- a/libwvdrmengine/cdm/Android.mk +++ b/libwvdrmengine/cdm/Android.mk @@ -39,7 +39,6 @@ LOCAL_SRC_FILES := \ $(PROFILER_SRC_DIR)/entry_writer.cpp \ $(PROFILER_SRC_DIR)/profiled_scope.cpp \ $(PROFILER_SRC_DIR)/profiler.cpp \ - $(PROFILER_SRC_DIR)/call_table.cpp \ $(PROFILER_SRC_DIR)/call_history.cpp LOCAL_MODULE := libcdm diff --git a/libwvdrmengine/cdm/profiler/include/call_table.h b/libwvdrmengine/cdm/profiler/include/call_table.h deleted file mode 100644 index f84c4ff9..00000000 --- a/libwvdrmengine/cdm/profiler/include/call_table.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef WVCDM_PROFILER_CALL_TABLE_H_ -#define WVCDM_PROFILER_CALL_TABLE_H_ - -#include -#include -#include - -namespace wvcdm { -namespace oemprofiler { - -class CallTable { - public: - class Row { - public: - Row(); - void Add(uint64_t sample); - - uint64_t GetSampleSize() const; - - uint64_t GetMin() const; - uint64_t GetMax() const; - - double GetMean() const; - double GetVariance() const; - - private: - uint64_t min_; - uint64_t max_; - uint64_t sample_size_; - double mean_; - double variance_m_; - double variance_s_; - - }; - - const Row* LookUp(uint64_t row_id) const; - - void Write(uint64_t row_id, uint64_t sample); - - void Read(std::vector& output) const; - - private: - std::map map_; -}; - -} // namespace oemprofiler -} // namespace wvcdm - -#endif diff --git a/libwvdrmengine/cdm/profiler/include/profiler.h b/libwvdrmengine/cdm/profiler/include/profiler.h index f12c1360..2dc0c5bf 100644 --- a/libwvdrmengine/cdm/profiler/include/profiler.h +++ b/libwvdrmengine/cdm/profiler/include/profiler.h @@ -3,7 +3,6 @@ #ifndef WVCDM_PROFILER_H_ #define WVCDM_PROFILER_H_ -#include "call_table.h" #include "call_history.h" namespace wvcdm { @@ -11,11 +10,9 @@ namespace oemprofiler { class Profiler { public: - static CallTable& GetTable(); static CallHistory& GetHistory(); private: - static CallTable global_table_; static CallHistory global_history_; }; diff --git a/libwvdrmengine/cdm/profiler/src/call_table.cpp b/libwvdrmengine/cdm/profiler/src/call_table.cpp deleted file mode 100644 index fe1b2306..00000000 --- a/libwvdrmengine/cdm/profiler/src/call_table.cpp +++ /dev/null @@ -1,103 +0,0 @@ -#include "call_table.h" - -#include - -#include "entry_writer.h" - -namespace wvcdm { -namespace oemprofiler { - -namespace { - const uint8_t kOutputVersionNumber = 0x00; -} - -CallTable::Row::Row() : - min_(std::numeric_limits::max()), - max_(0), - sample_size_(0), - mean_(0), - variance_m_(0), - variance_s_(0) { - -} - -void CallTable::Row::Add(uint64_t value) { - min_ = std::min(min_, value); - max_ = std::max(max_, value); - - mean_ = ((mean_ * sample_size_) + value) / (sample_size_ + 1.0); - sample_size_ += 1; - - // Welford's method for standard deviation and variance - const double old_m = variance_m_; - const double old_s = variance_s_; - variance_m_ = old_m + (value - old_m) / sample_size_; - variance_s_ = old_s + (value - variance_m_) * (value -old_m); -} - -uint64_t CallTable::Row::GetSampleSize() const { - return sample_size_; -} - -uint64_t CallTable::Row::GetMin() const { - return min_; -} - -uint64_t CallTable::Row::GetMax() const { - return max_; -} - -double CallTable::Row::GetMean() const { - return mean_; -} - -double CallTable::Row::GetVariance() const { - return sample_size_ > 1 ? variance_s_ / (sample_size_ - 1) : 0; -} - -const CallTable::Row* CallTable::LookUp(uint64_t row_id) const { - return map_.count(row_id) == 0 ? NULL : &map_.find(row_id)->second; -} - -void CallTable::Write(uint64_t row_id, uint64_t sample) { - if (map_.count(row_id) == 0) { - map_.insert(std::pair(row_id, Row())); - } - - map_[row_id].Add(sample); -} - -void CallTable::Read(std::vector& output) const { - output.push_back(kOutputVersionNumber); - - for (std::map::const_iterator it = map_.begin(); - it != map_.end(); ++it) { - - const uint64_t values_to_write[] = { - it->first, - it->second.GetSampleSize(), - it->second.GetMin(), - it->second.GetMax(), - static_cast(it->second.GetMean()), - // get the decimal places to the one-hundredths - static_cast(it->second.GetMean() * 100) % 100, - static_cast(it->second.GetVariance()), - // get the decimal places to the one-hundredths - static_cast(it->second.GetVariance() * 100) % 100 - }; - - const size_t kValuesToWriteSize = 8; - - for (size_t i = 0; i < kValuesToWriteSize; i++) { - EntryWriter writer; - writer.WriteVLV(values_to_write[i]); - - for (size_t w_i = 0; w_i < writer.GetSize(); w_i++) { - output.push_back(writer.GetData()[w_i]); - } - } - } -} - -} // namespace oemprofiler -} // namespace wvcdm diff --git a/libwvdrmengine/cdm/profiler/src/profiled_scope.cpp b/libwvdrmengine/cdm/profiler/src/profiled_scope.cpp index 5e7fefe2..93219db9 100644 --- a/libwvdrmengine/cdm/profiler/src/profiled_scope.cpp +++ b/libwvdrmengine/cdm/profiler/src/profiled_scope.cpp @@ -21,7 +21,6 @@ ProfiledScope::~ProfiledScope() { } void ProfiledScope::Submit(uint64_t end_time) const { - Profiler::GetTable().Write(fid_, end_time - start_time_); Profiler::GetHistory().Write( fid_, diff --git a/libwvdrmengine/cdm/profiler/src/profiler.cpp b/libwvdrmengine/cdm/profiler/src/profiler.cpp index 45f0a592..d5376810 100644 --- a/libwvdrmengine/cdm/profiler/src/profiler.cpp +++ b/libwvdrmengine/cdm/profiler/src/profiler.cpp @@ -5,13 +5,8 @@ namespace wvcdm { namespace oemprofiler { -CallTable Profiler::global_table_; CallHistory Profiler::global_history_; -CallTable& Profiler::GetTable() { - return global_table_; -} - CallHistory& Profiler::GetHistory() { return global_history_; } diff --git a/libwvdrmengine/mediadrm/src/WVDrmPlugin.cpp b/libwvdrmengine/mediadrm/src/WVDrmPlugin.cpp index 0722826f..7cc0b553 100644 --- a/libwvdrmengine/mediadrm/src/WVDrmPlugin.cpp +++ b/libwvdrmengine/mediadrm/src/WVDrmPlugin.cpp @@ -31,7 +31,6 @@ namespace { // profiler proterties constants static const android::String8 kProfilerHistoryTag("oemProfilerHistory"); - static const android::String8 kProfilerStatsTag("oemProfilerStats"); } namespace wvdrm { @@ -512,28 +511,11 @@ bool WVDrmPlugin::tryGettingOEMProfilingHistory(const String8& name, return false; } -bool WVDrmPlugin::tryGettingOEMProfilingStats( - const String8& name, - Vector& value) const { - - if (name == kProfilerStatsTag) { - std::vector tempValue; - oemprofiler::Profiler::GetTable().Read(tempValue); - value.appendArray(tempValue.data(), tempValue.size()); - - return true; - } - - return false; -} - status_t WVDrmPlugin::getPropertyByteArray(const String8& name, Vector& value) const { if (tryGettingOEMProfilingHistory(name, value)) { return android::OK; - } else if (tryGettingOEMProfilingStats(name, value)) { - return android::OK; } else if (name == "deviceUniqueId") { return queryProperty(QUERY_KEY_DEVICE_ID, value); } else if (name == "provisioningUniqueId") {