SF: Add composition strategy prediction stats
Track number of frames we attempted to predict
the composition strategy and the number of
frames it was successful. This should only be used
as a convenient way to debug locally. Composition
strategy prediction hit and misses are also tracked
via trace tags and can be extracted for metrics.
Enable stats: adb shell su root dumpsys SurfaceFlinger --timestats -enable
Dump stats: adb shell su root dumpsys SurfaceFlinger --timestats -dump -maxlayers 0
Clear stats: adb shell su root dumpsys SurfaceFlinger --timestats -clear
Test: adb shell
Bug: 220031739
Change-Id: Ifc35efa7ce110e82041f529b58acebfa1c325f36
diff --git a/services/surfaceflinger/CompositionEngine/src/Output.cpp b/services/surfaceflinger/CompositionEngine/src/Output.cpp
index 6595ed3..e99b70f 100644
--- a/services/surfaceflinger/CompositionEngine/src/Output.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Output.cpp
@@ -58,7 +58,8 @@
Output::~Output() = default;
namespace impl {
-
+using CompositionStrategyPredictionState =
+ OutputCompositionState::CompositionStrategyPredictionState;
namespace {
template <typename T>
@@ -970,6 +971,7 @@
std::optional<android::HWComposer::DeviceRequestedChanges> changes;
bool success = chooseCompositionStrategy(&changes);
resetCompositionStrategy();
+ outputState.strategyPrediction = CompositionStrategyPredictionState::DISABLED;
outputState.previousDeviceRequestedChanges = changes;
outputState.previousDeviceRequestedSuccess = success;
if (success) {
@@ -1012,7 +1014,8 @@
auto chooseCompositionSuccess = hwcResult.get();
const bool predictionSucceeded = dequeueSucceeded && changes == previousChanges;
- compositionResult.succeeded = predictionSucceeded;
+ state.strategyPrediction = predictionSucceeded ? CompositionStrategyPredictionState::SUCCESS
+ : CompositionStrategyPredictionState::FAIL;
if (!predictionSucceeded) {
ATRACE_NAME("CompositionStrategyPredictionMiss");
resetCompositionStrategy();
@@ -1056,15 +1059,15 @@
void Output::finishFrame(const CompositionRefreshArgs& refreshArgs, GpuCompositionResult&& result) {
ATRACE_CALL();
ALOGV(__FUNCTION__);
-
- if (!getState().isEnabled) {
+ const auto& outputState = getState();
+ if (!outputState.isEnabled) {
return;
}
std::optional<base::unique_fd> optReadyFence;
std::shared_ptr<renderengine::ExternalTexture> buffer;
base::unique_fd bufferFence;
- if (result.succeeded) {
+ if (outputState.strategyPrediction == CompositionStrategyPredictionState::SUCCESS) {
optReadyFence = std::move(result.fence);
} else {
if (result.bufferAvailable()) {