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

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

TimeStats: bound the stats pool size

On any device having TimeStats enabled, the stats pool will be cleared once per
day based on the stats pulling schedule. This change just adds an additional
protect in case the layer count explodes during a tracing period.

Test: TimeStatsTest
Change-Id: I3067239c12645008bceb61a1b7e59d8d6f89076a
parent 54322025
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -72,8 +72,10 @@ std::string TimeStats::miniDump() {

    std::string result = "TimeStats miniDump:\n";
    std::lock_guard<std::mutex> lock(mMutex);
    android::base::StringAppendF(&result, "Number of tracked layers is %zu\n",
    android::base::StringAppendF(&result, "Number of layers currently being tracked is %zu\n",
                                 mTimeStatsTracker.size());
    android::base::StringAppendF(&result, "Number of layers in the stats pool is %zu\n",
                                 mTimeStats.stats.size());
    return result;
}

@@ -250,6 +252,9 @@ void TimeStats::setPostTime(int32_t layerID, uint64_t frameNumber, const std::st
          postTime);

    std::lock_guard<std::mutex> lock(mMutex);
    if (!mTimeStats.stats.count(layerName) && mTimeStats.stats.size() >= MAX_NUM_LAYER_STATS) {
        return;
    }
    if (!mTimeStatsTracker.count(layerID) && mTimeStatsTracker.size() < MAX_NUM_LAYER_RECORDS &&
        layerNameIsValid(layerName)) {
        mTimeStatsTracker[layerID].layerName = layerName;
+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ private:
    GlobalRecord mGlobalRecord;

    static const size_t MAX_NUM_LAYER_RECORDS = 200;
    static const size_t MAX_NUM_LAYER_STATS = 200;
};

} // namespace impl