SF Timestats: add new metrics
Add the new metrics below:
1) dropped buffers per layer
2) post to acquire histogram
Stop tracking the start and end time for each layer since that doesn't
give any meaningful information. The total/dropped frame per layer is
good enough for now.
Test: dumpsys SurfaceFlinger --timestats <see go/sf-timestats for args>
Bug: b/110954467
Change-Id: I1c8a3a6cc76b7ec4a2e9ab86d9237af95fe9d1e1
diff --git a/services/surfaceflinger/TimeStats/timestatsproto/TimeStatsHelper.cpp b/services/surfaceflinger/TimeStats/timestatsproto/TimeStatsHelper.cpp
index 21f3ef3..b7b2778 100644
--- a/services/surfaceflinger/TimeStats/timestatsproto/TimeStatsHelper.cpp
+++ b/services/surfaceflinger/TimeStats/timestatsproto/TimeStatsHelper.cpp
@@ -68,12 +68,11 @@
}
std::string TimeStatsHelper::TimeStatsLayer::toString() const {
- std::string result = "";
+ std::string result = "\n";
StringAppendF(&result, "layerName = %s\n", layerName.c_str());
StringAppendF(&result, "packageName = %s\n", packageName.c_str());
- StringAppendF(&result, "statsStart = %lld\n", static_cast<long long int>(statsStart));
- StringAppendF(&result, "statsEnd = %lld\n", static_cast<long long int>(statsEnd));
- StringAppendF(&result, "totalFrames= %d\n", totalFrames);
+ StringAppendF(&result, "totalFrames = %d\n", totalFrames);
+ StringAppendF(&result, "droppedFrames = %d\n", droppedFrames);
auto iter = deltas.find("present2present");
if (iter != deltas.end()) {
StringAppendF(&result, "averageFPS = %.3f\n", 1000.0 / iter->second.averageTime());
@@ -90,10 +89,9 @@
std::string result = "SurfaceFlinger TimeStats:\n";
StringAppendF(&result, "statsStart = %lld\n", static_cast<long long int>(statsStart));
StringAppendF(&result, "statsEnd = %lld\n", static_cast<long long int>(statsEnd));
- StringAppendF(&result, "totalFrames= %d\n", totalFrames);
- StringAppendF(&result, "missedFrames= %d\n", missedFrames);
- StringAppendF(&result, "clientCompositionFrames= %d\n", clientCompositionFrames);
- StringAppendF(&result, "TimeStats for each layer is as below:\n");
+ StringAppendF(&result, "totalFrames = %d\n", totalFrames);
+ StringAppendF(&result, "missedFrames = %d\n", missedFrames);
+ StringAppendF(&result, "clientCompositionFrames = %d\n", clientCompositionFrames);
const auto dumpStats = generateDumpStats(maxLayers);
for (auto& ele : dumpStats) {
StringAppendF(&result, "%s", ele->toString().c_str());
@@ -106,15 +104,14 @@
SFTimeStatsLayerProto layerProto;
layerProto.set_layer_name(layerName);
layerProto.set_package_name(packageName);
- layerProto.set_stats_start(statsStart);
- layerProto.set_stats_end(statsEnd);
layerProto.set_total_frames(totalFrames);
+ layerProto.set_dropped_frames(droppedFrames);
for (auto& ele : deltas) {
SFTimeStatsDeltaProto* deltaProto = layerProto.add_deltas();
deltaProto->set_delta_name(ele.first);
for (auto& histEle : ele.second.hist) {
SFTimeStatsHistogramBucketProto* histProto = deltaProto->add_histograms();
- histProto->set_render_millis(histEle.first);
+ histProto->set_time_millis(histEle.first);
histProto->set_frame_count(histEle.second);
}
}
diff --git a/services/surfaceflinger/TimeStats/timestatsproto/include/timestatsproto/TimeStatsHelper.h b/services/surfaceflinger/TimeStats/timestatsproto/include/timestatsproto/TimeStatsHelper.h
index 1798555..99c891b 100644
--- a/services/surfaceflinger/TimeStats/timestatsproto/include/timestatsproto/TimeStatsHelper.h
+++ b/services/surfaceflinger/TimeStats/timestatsproto/include/timestatsproto/TimeStatsHelper.h
@@ -42,9 +42,8 @@
public:
std::string layerName;
std::string packageName;
- int64_t statsStart = 0;
- int64_t statsEnd = 0;
int32_t totalFrames = 0;
+ int32_t droppedFrames = 0;
std::unordered_map<std::string, Histogram> deltas;
std::string toString() const;
diff --git a/services/surfaceflinger/TimeStats/timestatsproto/timestats.proto b/services/surfaceflinger/TimeStats/timestatsproto/timestats.proto
index f29fbd1..ab7527e 100644
--- a/services/surfaceflinger/TimeStats/timestatsproto/timestats.proto
+++ b/services/surfaceflinger/TimeStats/timestatsproto/timestats.proto
@@ -20,46 +20,59 @@
option optimize_for = LITE_RUNTIME;
+// //depot/google3/java/com/google/android/apps/graphics/proto/timestats.proto
+// is based on this proto. Please only make valid protobuf changes to these
+// messages, and keep the other file in sync per Android release. Please also
+// do not include "option optimize_for = LITE_RUNTIME;" on google3 side.
+
+// Next tag: 7
message SFTimeStatsGlobalProto {
- // The start & end timestamps in UTC as
- // milliseconds since January 1, 1970
+ // The stats start time in UTC as seconds since January 1, 1970
optional int64 stats_start = 1;
+ // The stats end time in UTC as seconds since January 1, 1970
optional int64 stats_end = 2;
- // Total frames
+ // Total number of frames presented during tracing period.
optional int32 total_frames = 3;
// Total missed frames of SurfaceFlinger.
optional int32 missed_frames = 4;
// Total frames fallback to client composition.
optional int32 client_composition_frames = 5;
-
+ // Stats per layer. Apps could have multiple layers.
repeated SFTimeStatsLayerProto stats = 6;
}
+// Next tag: 8
message SFTimeStatsLayerProto {
- // The layer name
+ // The name of the visible view layer.
optional string layer_name = 1;
- // The package name
+ // The package name of the application owning this layer.
optional string package_name = 2;
- // The start & end timestamps in UTC as
- // milliseconds since January 1, 1970
+ // The stats start time in UTC as seconds since January 1, 1970
optional int64 stats_start = 3;
+ // The stats end time in UTC as seconds since January 1, 1970
optional int64 stats_end = 4;
- // Distinct frame count.
+ // Total number of frames presented during tracing period.
optional int32 total_frames = 5;
-
+ // Total number of frames dropped by SurfaceFlinger.
+ optional int32 dropped_frames = 7;
+ // There are multiple timestamps tracked in SurfaceFlinger, and these are the
+ // histograms of deltas between different combinations of those timestamps.
repeated SFTimeStatsDeltaProto deltas = 6;
}
+// Next tag: 3
message SFTimeStatsDeltaProto {
// Name of the time interval
optional string delta_name = 1;
- // Histogram of the delta time
+ // Histogram of the delta time. There should be at most 85 buckets ranging
+ // from [0ms, 1ms) to [1000ms, infinity)
repeated SFTimeStatsHistogramBucketProto histograms = 2;
}
+// Next tag: 3
message SFTimeStatsHistogramBucketProto {
- // Lower bound of render time in milliseconds.
- optional int32 render_millis = 1;
+ // Lower bound of time interval in milliseconds.
+ optional int32 time_millis = 1;
// Number of frames in the bucket.
optional int32 frame_count = 2;
}