Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5154a379 authored by Yao Chen's avatar Yao Chen
Browse files

Adding multi layer aggregation in DurationMetric

Newly supported metrics examples:

1) Compute [Total|Max] duration of [an app] holding [ANY] wake lock while [this app] is in
   [background] and [screen off], bucket size 30seconds, and slice output by uid.

2) Compute [Total|Max] duration of [ANY app] holding [ANY] wake lock while [this app] is in
   [background] and [screen off], bucket size 30 seconds.

+ DurationMetric proto has a "what" which is a SimpleCondition. It defines the atom level start
  and stop of the duration timer, and it has its atom dimension. e.g., for wake locks, the atom
  dimensions wil be uid and wl name.

+ Now dimension is explicitly specified in SimpleCondition proto instead of inferred from the "link"

+ Added support for "Or" and "Max" through 2 layers of aggregation.

TODO: (1) The way we track slicedCondition in duration metric is not efficient. optimize!
      (2) The output dimension should all use int32 instead of KeyMatcher. Fix in a future cl.

Test: Added some unit tests using gmock. Will add more unit tests.

Change-Id: I58a827624f01f9a54fcb80709c4de4ff94a8bc67
parent 473b3345
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -12,3 +12,6 @@ IndentWidth: 4
PointerAlignment: Left
TabWidth: 4
AccessModifierOffset: -4
IncludeCategories:
  - Regex:    '^"Log\.h"'
    Priority:    -1
+5 −1
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@ statsd_common_src := \
    src/metrics/EventMetricProducer.cpp \
    src/metrics/CountMetricProducer.cpp \
    src/metrics/DurationMetricProducer.cpp \
    src/metrics/duration_helper/OringDurationTracker.cpp \
    src/metrics/duration_helper/MaxDurationTracker.cpp \
    src/metrics/MetricsManager.cpp \
    src/metrics/metrics_manager_util.cpp \
    src/packages/UidMap.cpp \
@@ -142,7 +144,9 @@ LOCAL_SRC_FILES := \
    tests/LogEntryMatcher_test.cpp \
    tests/LogReader_test.cpp \
    tests/MetricsManager_test.cpp \
    tests/UidMap_test.cpp
    tests/UidMap_test.cpp \
    tests/OringDurationTracker_test.cpp \
    tests/MaxDurationTracker_test.cpp


LOCAL_STATIC_LIBRARIES := \
+9 −1
Original line number Diff line number Diff line
@@ -231,6 +231,14 @@ void StatsService::print_cmd_help(FILE* out) {
    fprintf(out, "                parameter on eng builds.  If UID is omitted the calling\n");
    fprintf(out, "                uid is used.\n");
    fprintf(out, "  NAME          The per-uid name to use\n");
    fprintf(out, "\n");
    fprintf(out, "\n");
    fprintf(out, "usage: adb shell cmd stats dump-report [UID] NAME\n");
    fprintf(out, "  Dump all metric data for a configuration.\n");
    fprintf(out, "  UID           The uid of the configuration. It is only possible to pass\n");
    fprintf(out, "                the UID parameter on eng builds. If UID is omitted the\n");
    fprintf(out, "                calling uid is used.\n");
    fprintf(out, "  NAME          The name of the configuration\n");
}

status_t StatsService::cmd_config(FILE* in, FILE* out, FILE* err, Vector<String8>& args) {
@@ -312,7 +320,7 @@ status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String
            // Automatically pick the UID
            uid = IPCThreadState::self()->getCallingUid();
            // TODO: What if this isn't a binder call? Should we fail?
            name.assign(args[2].c_str(), args[2].size());
            name.assign(args[1].c_str(), args[1].size());
            good = true;
        } else if (argCount == 3) {
            // If it's a userdebug or eng build, then the shell user can
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

#define DEBUG true  // STOPSHIP if true
#include "Log.h"

#include "CombinationConditionTracker.h"

#include <log/logprint.h>
+0 −2
Original line number Diff line number Diff line
@@ -46,8 +46,6 @@ public:
                        const std::vector<sp<ConditionTracker>>& allConditions,
                        std::vector<ConditionState>& conditionCache) override;

    void addDimensions(const std::vector<KeyMatcher>& keyMatchers) override{};

private:
    LogicalOperation mLogicalOperation;
    // Store index of the children Conditions.
Loading