diff options
author | Michael Butler <butlermichael@google.com> | 2022-05-12 21:39:50 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-05-12 21:39:50 +0000 |
commit | b47e2dca0b79451e4c3e5a503fcea9da3315c8eb (patch) | |
tree | 0894426d6d236b013b1045a2c0da31f39caf7eda | |
parent | 024cbf525d3e34f299c1c09989f4406f4253cb4d (diff) | |
parent | 34745e9b0bb59629843a7cb1b66dc667f1f7375c (diff) | |
download | NeuralNetworks-b47e2dca0b79451e4c3e5a503fcea9da3315c8eb.tar.gz |
Cleanup NNAPI platform telemetry code am: 34745e9b0b
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/NeuralNetworks/+/18332263
Change-Id: I72850cfa6547bac11d2d028af70da0629b0ec53a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | runtime/Android.bp | 2 | ||||
-rw-r--r-- | runtime/Telemetry.cpp | 6 | ||||
-rw-r--r-- | runtime/TelemetryStatsd.cpp (renamed from runtime/TelemetryWestworld.cpp) | 34 | ||||
-rw-r--r-- | runtime/TelemetryStatsd.h (renamed from runtime/TelemetryWestworld.h) | 18 | ||||
-rw-r--r-- | runtime/test/Android.bp | 2 | ||||
-rw-r--r-- | runtime/test/TestStatsdTelemetry.cpp (renamed from runtime/test/TestWestworldTelemetry.cpp) | 40 |
6 files changed, 51 insertions, 51 deletions
diff --git a/runtime/Android.bp b/runtime/Android.bp index 3478d35b5..7bc3b1b9d 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -107,7 +107,7 @@ cc_defaults { generated_headers: ["statslog_neuralnetworks.h"], export_generated_headers: ["statslog_neuralnetworks.h"], srcs: [ - "TelemetryWestworld.cpp", + "TelemetryStatsd.cpp", ], shared_libs: [ "libnativewindow", diff --git a/runtime/Telemetry.cpp b/runtime/Telemetry.cpp index c82aad31e..5adf0f8b1 100644 --- a/runtime/Telemetry.cpp +++ b/runtime/Telemetry.cpp @@ -30,7 +30,7 @@ #include "Tracing.h" #if defined(__ANDROID__) && !defined(NN_COMPATIBILITY_LIBRARY_BUILD) -#include "TelemetryWestworld.h" +#include "TelemetryStatsd.h" #endif // defined(__ANDROID__) && !defined(NN_COMPATIBILITY_LIBRARY_BUILD) namespace android::nn::telemetry { @@ -176,7 +176,7 @@ void onCompilationFinish(CompilationBuilder* c, int resultCode) { #if defined(__ANDROID__) && !defined(NN_COMPATIBILITY_LIBRARY_BUILD) if (DeviceManager::get()->isPlatformTelemetryEnabled()) { - logCompilationToWestworld(&info); + logCompilationToStatsd(&info); } #endif // defined(__ANDROID__) && !defined(NN_COMPATIBILITY_LIBRARY_BUILD) @@ -233,7 +233,7 @@ void onExecutionFinish(ExecutionBuilder* e, ExecutionMode executionMode, int res #if defined(__ANDROID__) && !defined(NN_COMPATIBILITY_LIBRARY_BUILD) if (DeviceManager::get()->isPlatformTelemetryEnabled()) { - logExecutionToWestworld(&info); + logExecutionToStatsd(&info); } #endif // defined(__ANDROID__) && !defined(NN_COMPATIBILITY_LIBRARY_BUILD) diff --git a/runtime/TelemetryWestworld.cpp b/runtime/TelemetryStatsd.cpp index cc53fcc9e..db8318cf7 100644 --- a/runtime/TelemetryWestworld.cpp +++ b/runtime/TelemetryStatsd.cpp @@ -14,9 +14,9 @@ * limitations under the License. */ -#define LOG_TAG "TelemetryWestworld" +#define LOG_TAG "TelemetryStatsd" -#include "TelemetryWestworld.h" +#include "TelemetryStatsd.h" #include <android-base/logging.h> #include <android-base/no_destructor.h> @@ -39,10 +39,10 @@ namespace android::nn::telemetry { namespace { constexpr uint64_t kNoTimeReportedRuntime = std::numeric_limits<uint64_t>::max(); -constexpr int64_t kNoTimeReportedWestworld = std::numeric_limits<int64_t>::max(); +constexpr int64_t kNoTimeReportedStatsd = std::numeric_limits<int64_t>::max(); constexpr size_t kInitialChannelSize = 100; -// WestWorld specifies that "Atom logging frequency should not exceed once per 10 milliseconds (i.e. +// Statsd specifies that "Atom logging frequency should not exceed once per 10 milliseconds (i.e. // consecutive atom calls should be at least 10 milliseconds apart)." A quiet period of 100ms is // chosen here to reduce the chance that the NNAPI logs too frequently, even from separate // applications. @@ -55,16 +55,16 @@ int32_t getUid() { constexpr int64_t nanosToMillis(uint64_t time) { constexpr uint64_t kNanosPerMilli = 1'000'000; - return time == kNoTimeReportedRuntime ? kNoTimeReportedWestworld : time / kNanosPerMilli; + return time == kNoTimeReportedRuntime ? kNoTimeReportedStatsd : time / kNanosPerMilli; } constexpr int64_t nanosToMicros(uint64_t time) { constexpr uint64_t kNanosPerMicro = 1'000; - return time == kNoTimeReportedRuntime ? kNoTimeReportedWestworld : time / kNanosPerMicro; + return time == kNoTimeReportedRuntime ? kNoTimeReportedStatsd : time / kNanosPerMicro; } AtomValue::AccumulatedTiming accumulatedTimingFrom(int64_t timing) { - if (timing == kNoTimeReportedWestworld) { + if (timing == kNoTimeReportedStatsd) { return {}; } return { @@ -182,8 +182,8 @@ int32_t convertResultCode(int32_t resultCode) { : ANEURALNETWORKS_OP_FAILED; } -void logAtomToWestworld(Atom&& atom) { - NNTRACE_RT(NNTRACE_PHASE_UNSPECIFIED, "logAtomToWestworld"); +void logAtomToStatsd(Atom&& atom) { + NNTRACE_RT(NNTRACE_PHASE_UNSPECIFIED, "logAtomToStatsd"); const auto& [key, value] = atom; if (!key.isExecution) { @@ -234,8 +234,8 @@ void logAtomToWestworld(Atom&& atom) { } } -AsyncLogger& getWestworldLogger() { - static base::NoDestructor<AsyncLogger> logger(logAtomToWestworld, kMinimumLoggingQuietPeriod); +AsyncLogger& getStatsdLogger() { + static base::NoDestructor<AsyncLogger> logger(logAtomToStatsd, kMinimumLoggingQuietPeriod); return *logger; } @@ -430,14 +430,14 @@ Atom createAtomFrom(const DiagnosticExecutionInfo* info) { return atom; } -void logCompilationToWestworld(const DiagnosticCompilationInfo* info) { - NNTRACE_RT(NNTRACE_PHASE_UNSPECIFIED, "logCompilationWestworld"); - getWestworldLogger().write(createAtomFrom(info)); +void logCompilationToStatsd(const DiagnosticCompilationInfo* info) { + NNTRACE_RT(NNTRACE_PHASE_UNSPECIFIED, "logCompilationStatsd"); + getStatsdLogger().write(createAtomFrom(info)); } -void logExecutionToWestworld(const DiagnosticExecutionInfo* info) { - NNTRACE_RT(NNTRACE_PHASE_UNSPECIFIED, "logExecutionWestworld"); - getWestworldLogger().write(createAtomFrom(info)); +void logExecutionToStatsd(const DiagnosticExecutionInfo* info) { + NNTRACE_RT(NNTRACE_PHASE_UNSPECIFIED, "logExecutionStatsd"); + getStatsdLogger().write(createAtomFrom(info)); } } // namespace android::nn::telemetry diff --git a/runtime/TelemetryWestworld.h b/runtime/TelemetryStatsd.h index da6df5d4a..d9cf2c656 100644 --- a/runtime/TelemetryWestworld.h +++ b/runtime/TelemetryStatsd.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_FRAMEWORKS_ML_NN_RUNTIME_TELEMETRY_WESTWORLD_H -#define ANDROID_FRAMEWORKS_ML_NN_RUNTIME_TELEMETRY_WESTWORLD_H +#ifndef ANDROID_FRAMEWORKS_ML_NN_RUNTIME_TELEMETRY_STATSD_H +#define ANDROID_FRAMEWORKS_ML_NN_RUNTIME_TELEMETRY_STATSD_H #include <android-base/thread_annotations.h> @@ -94,7 +94,7 @@ struct AtomValue { void combineAtomValues(AtomValue* acculatedValue, const AtomValue& value); -// Atom type to be sent to Westworld Telemetry +// Atom type to be sent to Statsd Telemetry using Atom = std::pair<AtomKey, AtomValue>; // Helper class to locally aggregate and retrieve telemetry atoms. @@ -118,8 +118,8 @@ class AtomAggregator { using LoggerFn = std::function<void(Atom&&)>; // AsyncLogger minimizes the call to `write`, so that the calling thread which handles the -// compilation or execution is not slowed down by writing to WestWorld. Instead, AsyncLogger -// contains a dedicated thread that will handle logging to WestWorld in the background. +// compilation or execution is not slowed down by writing to statsd. Instead, AsyncLogger +// contains a dedicated thread that will handle logging to statsd in the background. // This class is thread-safe. class AsyncLogger { public: @@ -155,10 +155,10 @@ class AsyncLogger { Atom createAtomFrom(const DiagnosticCompilationInfo* info); Atom createAtomFrom(const DiagnosticExecutionInfo* info); -// Log an Atom to WestWorld from a diagnostic info object. -void logCompilationToWestworld(const DiagnosticCompilationInfo* info); -void logExecutionToWestworld(const DiagnosticExecutionInfo* info); +// Log an Atom to statsd from a diagnostic info object. +void logCompilationToStatsd(const DiagnosticCompilationInfo* info); +void logExecutionToStatsd(const DiagnosticExecutionInfo* info); } // namespace android::nn::telemetry -#endif // ANDROID_FRAMEWORKS_ML_NN_RUNTIME_TELEMETRY_WESTWORLD_H +#endif // ANDROID_FRAMEWORKS_ML_NN_RUNTIME_TELEMETRY_STATSD_H diff --git a/runtime/test/Android.bp b/runtime/test/Android.bp index b094fb2d2..57addd92b 100644 --- a/runtime/test/Android.bp +++ b/runtime/test/Android.bp @@ -210,7 +210,7 @@ cc_test { target: { android: { test_config: "AndroidTest_NeuralNetworksTest_static.xml", - srcs: ["TestWestworldTelemetry.cpp"], + srcs: ["TestStatsdTelemetry.cpp"], }, host: { cflags: [ diff --git a/runtime/test/TestWestworldTelemetry.cpp b/runtime/test/TestStatsdTelemetry.cpp index c8b2559a0..715f26652 100644 --- a/runtime/test/TestWestworldTelemetry.cpp +++ b/runtime/test/TestStatsdTelemetry.cpp @@ -21,7 +21,7 @@ #include <numeric> #include "Telemetry.h" -#include "TelemetryWestworld.h" +#include "TelemetryStatsd.h" namespace android::nn::telemetry { @@ -98,18 +98,18 @@ AtomValue::AccumulatedTiming accumulatedTimingsFrom(std::initializer_list<int64_ }; } -TEST(WestworldTelemetryTest, AtomKeyEquality) { +TEST(StatsdTelemetryTest, AtomKeyEquality) { EXPECT_EQ(kExampleKey, kExampleKey); } -TEST(WestworldTelemetryTest, AtomKeyLessThan) { +TEST(StatsdTelemetryTest, AtomKeyLessThan) { const auto key1 = kExampleKey; auto key2 = key1; key2.errorCode = ANEURALNETWORKS_DEAD_OBJECT; EXPECT_LT(key1, key2); } -TEST(WestworldTelemetryTest, CombineAtomValues) { +TEST(StatsdTelemetryTest, CombineAtomValues) { AtomValue value1 = { .count = 3, .compilationTimeMillis = accumulatedTimingsFrom({50, 100, 150}), @@ -127,7 +127,7 @@ TEST(WestworldTelemetryTest, CombineAtomValues) { EXPECT_EQ(value1, valueResult); } -TEST(WestworldTelemetryTest, CombineAtomValueWithLeftIdentity) { +TEST(StatsdTelemetryTest, CombineAtomValueWithLeftIdentity) { AtomValue value1 = {}; const AtomValue value2 = { .count = 1, @@ -139,7 +139,7 @@ TEST(WestworldTelemetryTest, CombineAtomValueWithLeftIdentity) { EXPECT_EQ(value1, valueResult); } -TEST(WestworldTelemetryTest, CombineAtomValueWithRightIdentity) { +TEST(StatsdTelemetryTest, CombineAtomValueWithRightIdentity) { AtomValue value1 = { .count = 3, .compilationTimeMillis = accumulatedTimingsFrom({50, 100, 150}), @@ -151,18 +151,18 @@ TEST(WestworldTelemetryTest, CombineAtomValueWithRightIdentity) { EXPECT_EQ(value1, valueResult); } -TEST(WestworldTelemetryTest, AtomAggregatorStartEmpty) { +TEST(StatsdTelemetryTest, AtomAggregatorStartEmpty) { AtomAggregator aggregator; EXPECT_TRUE(aggregator.empty()); } -TEST(WestworldTelemetryTest, AtomAggregatorNotEmptyAfterPush) { +TEST(StatsdTelemetryTest, AtomAggregatorNotEmptyAfterPush) { AtomAggregator aggregator; aggregator.push({kExampleKey, {}}); EXPECT_FALSE(aggregator.empty()); } -TEST(WestworldTelemetryTest, AtomAggregatorEmptyAfterPop) { +TEST(StatsdTelemetryTest, AtomAggregatorEmptyAfterPop) { AtomAggregator aggregator; aggregator.push({kExampleKey, {}}); const auto [k, v] = aggregator.pop(); @@ -170,7 +170,7 @@ TEST(WestworldTelemetryTest, AtomAggregatorEmptyAfterPop) { EXPECT_EQ(k, kExampleKey); } -TEST(WestworldTelemetryTest, AtomAggregatorTwoDifferentKeys) { +TEST(StatsdTelemetryTest, AtomAggregatorTwoDifferentKeys) { const auto key1 = kExampleKey; auto key2 = key1; key2.executionMode = ExecutionMode::ASYNC; @@ -188,7 +188,7 @@ TEST(WestworldTelemetryTest, AtomAggregatorTwoDifferentKeys) { EXPECT_FALSE(aggregator.empty()); } -TEST(WestworldTelemetryTest, AtomAggregatorTwoSameKeys) { +TEST(StatsdTelemetryTest, AtomAggregatorTwoSameKeys) { const auto key1 = kExampleKey; const auto value1 = AtomValue{.count = 2}; const auto value2 = AtomValue{.count = 3}; @@ -204,7 +204,7 @@ TEST(WestworldTelemetryTest, AtomAggregatorTwoSameKeys) { EXPECT_TRUE(aggregator.empty()); } -TEST(WestworldTelemetryTest, AtomAggregatorPush) { +TEST(StatsdTelemetryTest, AtomAggregatorPush) { const AtomKey key1 = kExampleKey; AtomKey key2 = key1; key2.executionMode = ExecutionMode::ASYNC; @@ -227,7 +227,7 @@ TEST(WestworldTelemetryTest, AtomAggregatorPush) { EXPECT_TRUE(aggregator.empty()); } -TEST(WestworldTelemetryTest, AsyncLoggerTeardownWhileWaitingForData) { +TEST(StatsdTelemetryTest, AsyncLoggerTeardownWhileWaitingForData) { constexpr auto fn = [](Atom&& /*atom*/) {}; const auto start = Clock::now(); { AsyncLogger logger(fn, kLongTime); } @@ -235,7 +235,7 @@ TEST(WestworldTelemetryTest, AsyncLoggerTeardownWhileWaitingForData) { EXPECT_LT(elapsed, kLongTime); } -TEST(WestworldTelemetryTest, AsyncLoggerTeardownDuringSleep) { +TEST(StatsdTelemetryTest, AsyncLoggerTeardownDuringSleep) { Signal loggingOccurred; auto fn = [&loggingOccurred](Atom&& /*atom*/) mutable { loggingOccurred.signal(); }; @@ -250,7 +250,7 @@ TEST(WestworldTelemetryTest, AsyncLoggerTeardownDuringSleep) { EXPECT_LT(elapsed, kLongTime); } -TEST(WestworldTelemetryTest, AsyncLoggerVerifyQuietPeriod) { +TEST(StatsdTelemetryTest, AsyncLoggerVerifyQuietPeriod) { std::atomic<uint32_t> count = 0; Signal loggingOccurred; const auto fn = [&count, &loggingOccurred](Atom&& /*atom*/) { @@ -276,7 +276,7 @@ TEST(WestworldTelemetryTest, AsyncLoggerVerifyQuietPeriod) { EXPECT_EQ(count, 1u); } -TEST(WestworldTelemetryTest, AsyncLoggerVerifyAllDataSent) { +TEST(StatsdTelemetryTest, AsyncLoggerVerifyAllDataSent) { const uint32_t targetCount = ANEURALNETWORKS_DEAD_OBJECT - ANEURALNETWORKS_NO_ERROR + 1; std::atomic<uint32_t> count = 0; Signal allDataSent; @@ -301,7 +301,7 @@ TEST(WestworldTelemetryTest, AsyncLoggerVerifyAllDataSent) { EXPECT_EQ(count, targetCount); } -TEST(WestworldTelemetryTest, createAtomFromCompilationInfoWhenNoError) { +TEST(StatsdTelemetryTest, createAtomFromCompilationInfoWhenNoError) { const DiagnosticCompilationInfo info{ .modelArchHash = kExampleModelArchHash.data(), .deviceId = kExampleDeviceId, @@ -341,7 +341,7 @@ TEST(WestworldTelemetryTest, createAtomFromCompilationInfoWhenNoError) { EXPECT_EQ(value.durationHardwareMicros, kNoAggregateTiming); } -TEST(WestworldTelemetryTest, createAtomFromCompilationInfoWhenError) { +TEST(StatsdTelemetryTest, createAtomFromCompilationInfoWhenError) { const DiagnosticCompilationInfo info{ .modelArchHash = kExampleModelArchHash.data(), .deviceId = kExampleDeviceId, @@ -378,7 +378,7 @@ TEST(WestworldTelemetryTest, createAtomFromCompilationInfoWhenError) { EXPECT_EQ(value.durationHardwareMicros, kNoAggregateTiming); } -TEST(WestworldTelemetryTest, createAtomFromExecutionInfoWhenNoError) { +TEST(StatsdTelemetryTest, createAtomFromExecutionInfoWhenNoError) { const DiagnosticExecutionInfo info{ .modelArchHash = kExampleModelArchHash.data(), .deviceId = kExampleDeviceId, @@ -426,7 +426,7 @@ TEST(WestworldTelemetryTest, createAtomFromExecutionInfoWhenNoError) { EXPECT_EQ(value.durationHardwareMicros, durationHardwareMicros); } -TEST(WestworldTelemetryTest, createAtomFromExecutionInfoWhenError) { +TEST(StatsdTelemetryTest, createAtomFromExecutionInfoWhenError) { const DiagnosticExecutionInfo info{ .modelArchHash = kExampleModelArchHash.data(), .deviceId = kExampleDeviceId, |