Use zetasketch for input statistics
Switch LatencyAggregator to use the actual zetasketch library. Report
the data to westworld via 2 atoms. 1 atom is for slow events, and 1 is
for latency sketches.
Estimating < 25 Kb per atom after few minutes of non-stop interaction with the screen.
Added a hard limit at 20 Kb
Dumped the data to a file on the device, and then read that data using
the full zetasketch implementation. Confirmed that the data looks OK.
Bug: 167947340
Test: adb shell dumpsys input and review the size of the resulting
sketches
Change-Id: I69b0f3753c86226886186d5f6edd779d2f9404e5
diff --git a/services/inputflinger/dispatcher/LatencyAggregator.h b/services/inputflinger/dispatcher/LatencyAggregator.h
index ce54360..ed5731f 100644
--- a/services/inputflinger/dispatcher/LatencyAggregator.h
+++ b/services/inputflinger/dispatcher/LatencyAggregator.h
@@ -17,6 +17,7 @@
#ifndef _UI_INPUT_INPUTDISPATCHER_LATENCYAGGREGATOR_H
#define _UI_INPUT_INPUTDISPATCHER_LATENCYAGGREGATOR_H
+#include <kll.h>
#include <statslog.h>
#include <utils/Timers.h>
@@ -46,16 +47,6 @@
// GraphicsTimeline::PRESENT_TIME
/**
- * TODO(b/167947340): Replace this class with a KLL sketch
- */
-class Sketch {
-public:
- void addValue(nsecs_t value);
- android::util::BytesField serialize();
- void reset();
-};
-
-/**
* Keep sketches of the provided events and report slow events
*/
class LatencyAggregator final : public InputEventTimelineProcessor {
@@ -86,8 +77,12 @@
// ---------- Statistics handling ----------
void processStatistics(const InputEventTimeline& timeline);
// Sketches
- std::array<Sketch, SketchIndex::SIZE> mDownSketches;
- std::array<Sketch, SketchIndex::SIZE> mMoveSketches;
+ std::array<std::unique_ptr<dist_proc::aggregation::KllQuantile>, SketchIndex::SIZE>
+ mDownSketches;
+ std::array<std::unique_ptr<dist_proc::aggregation::KllQuantile>, SketchIndex::SIZE>
+ mMoveSketches;
+ // How many events have been processed so far
+ size_t mNumSketchEventsProcessed = 0;
};
} // namespace android::inputdispatcher