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

Commit c5f2c455 authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

SF TimeStats: change the container of TimeRecord

The current container of TimeRecord is std::vector which behaves not
well when it tries to erase an element on the front. This change update
the container to std::deque instead.

Test: dumpsys SurfaceFlinger --timestats <see go/sf-timestats for args>
Bug: b/70388650
Change-Id: Ib3f695f46eb21dc27b0ed725b86764331f304be2
parent edb393d1
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ void TimeStats::flushAvailableRecordsToStatsLocked(const std::string& layerName)

    LayerRecord& layerRecord = timeStatsTracker[layerName];
    TimeRecord& prevTimeRecord = layerRecord.prevTimeRecord;
    std::vector<TimeRecord>& timeRecords = layerRecord.timeRecords;
    std::deque<TimeRecord>& timeRecords = layerRecord.timeRecords;
    while (!timeRecords.empty()) {
        if (!recordReadyLocked(layerName, &timeRecords[0])) break;
        ALOGV("[%s]-[%" PRIu64 "]-presentFenceTime[%" PRId64 "]", layerName.c_str(),
@@ -199,8 +199,7 @@ void TimeStats::flushAvailableRecordsToStatsLocked(const std::string& layerName)
            timeStats.stats[layerName].statsEnd = static_cast<int64_t>(std::time(0));
        }
        prevTimeRecord = timeRecords[0];
        // TODO(zzyiwei): change timeRecords to use std::deque
        timeRecords.erase(timeRecords.begin());
        timeRecords.pop_front();
        layerRecord.waitData--;
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@
#include <utils/String8.h>
#include <utils/Vector.h>

#include <deque>
#include <mutex>
#include <unordered_map>
#include <vector>

using namespace android::surfaceflinger;

@@ -57,7 +57,7 @@ class TimeStats {
        // fences to signal, but rather waiting to receive those fences/timestamps.
        int32_t waitData = -1;
        TimeRecord prevTimeRecord;
        std::vector<TimeRecord> timeRecords;
        std::deque<TimeRecord> timeRecords;
    };

public: