diff options
author | John Reck <jreck@google.com> | 2017-01-19 15:56:21 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2017-02-21 09:49:10 -0800 |
commit | df1742ed47da1e9b61afeae16fa448d5302a8aa0 (patch) | |
tree | 7986faf156f39bbe218ab13bad3ae5a1ea3dd581 /libs/hwui/JankTracker.cpp | |
parent | f8a420097e54a369d3bd1aa152ea0eea58ff5c94 (diff) |
Overhaul GraphicsStatsService
* LRU cache of recently-used is dead, replaced
disk storage
* ASHMEM size is read from native by the system service,
no longer requires keeping a sizeof() in sync with a
constant in Java
* Supports dumping in proto format by passing --proto
* Rotates logs on a daily basis
* Keeps a history of the most recent 3 days
Bug: 33705836
Test: Manual. Verified log rotating works by setting it up to
rotate every minute instead of day. Confirmed /data/system/graphicsstats
only has the most recent 3 entries after several minutes
Change-Id: Ib84bafb26c58701cc86f123236de4fff01aaa4aa
Diffstat (limited to 'libs/hwui/JankTracker.cpp')
-rw-r--r-- | libs/hwui/JankTracker.cpp | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/libs/hwui/JankTracker.cpp b/libs/hwui/JankTracker.cpp index 2132c2b171dc..7be71eec4f76 100644 --- a/libs/hwui/JankTracker.cpp +++ b/libs/hwui/JankTracker.cpp @@ -110,7 +110,7 @@ static uint32_t frameCountIndexForFrameTime(nsecs_t frameTime) { } // Only called when dumping stats, less performance sensitive -static uint32_t frameTimeForFrameCountIndex(uint32_t index) { +int32_t JankTracker::frameTimeForFrameCountIndex(uint32_t index) { index = index + kBucketMinThreshold; if (index > kBucket2msIntervals) { index += (index - kBucket2msIntervals); @@ -123,6 +123,10 @@ static uint32_t frameTimeForFrameCountIndex(uint32_t index) { return index; } +int32_t JankTracker::frameTimeForSlowFrameCountIndex(uint32_t index) { + return (index * kSlowFrameBucketIntervalMs) + kSlowFrameBucketStartMs; +} + JankTracker::JankTracker(const DisplayInfo& displayInfo) { // By default this will use malloc memory. It may be moved later to ashmem // if there is shared space for it and a request comes in to do that. @@ -161,8 +165,25 @@ void JankTracker::freeData() { mData = nullptr; } +void JankTracker::rotateStorage() { + // If we are mapped we want to stop using the ashmem backend and switch to malloc + // We are expecting a switchStorageToAshmem call to follow this, but it's not guaranteed + // If we aren't sitting on top of ashmem then just do a reset() as it's functionally + // equivalent do a free, malloc, reset. + if (mIsMapped) { + freeData(); + mData = new ProfileData; + } + reset(); +} + void JankTracker::switchStorageToAshmem(int ashmemfd) { int regionSize = ashmem_get_size_region(ashmemfd); + if (regionSize < 0) { + int err = errno; + ALOGW("Failed to get ashmem region size from fd %d, err %d %s", ashmemfd, err, strerror(err)); + return; + } if (regionSize < static_cast<int>(sizeof(ProfileData))) { ALOGW("Ashmem region is too small! Received %d, required %u", regionSize, static_cast<unsigned int>(sizeof(ProfileData))); @@ -279,15 +300,19 @@ void JankTracker::addFrame(const FrameInfo& frame) { } } -void JankTracker::dumpBuffer(const void* buffer, size_t bufsize, int fd) { - if (bufsize < sizeof(ProfileData)) { - return; +void JankTracker::dumpData(int fd, const ProfileDataDescription* description, const ProfileData* data) { + if (description) { + switch (description->type) { + case JankTrackerType::Generic: + break; + case JankTrackerType::Package: + dprintf(fd, "\nPackage: %s", description->name.c_str()); + break; + case JankTrackerType::Window: + dprintf(fd, "\nWindow: %s", description->name.c_str()); + break; + } } - const ProfileData* data = reinterpret_cast<const ProfileData*>(buffer); - dumpData(data, fd); -} - -void JankTracker::dumpData(const ProfileData* data, int fd) { if (sFrameStart != FrameInfoIndex::IntendedVsync) { dprintf(fd, "\nNote: Data has been filtered!"); } @@ -308,7 +333,7 @@ void JankTracker::dumpData(const ProfileData* data, int fd) { data->frameCounts[i]); } for (size_t i = 0; i < data->slowFrameCounts.size(); i++) { - dprintf(fd, " %zums=%u", (i * kSlowFrameBucketIntervalMs) + kSlowFrameBucketStartMs, + dprintf(fd, " %ums=%u", frameTimeForSlowFrameCountIndex(i), data->slowFrameCounts[i]); } dprintf(fd, "\n"); |