Loading services/mediaresourcemanager/ResourceManagerMetrics.cpp +60 −23 Original line number Diff line number Diff line Loading @@ -447,6 +447,42 @@ void ResourceManagerMetrics::pushConcurrentUsageReport(int32_t pid, uid_t uid) { #endif } inline void pushReclaimStats(int32_t callingPid, int32_t requesterUid, int requesterPriority, const std::string& clientName, int32_t noOfConcurrentCodecs, int32_t reclaimStatus, int32_t noOfCodecsReclaimed = 0, int32_t targetIndex = -1, int32_t targetClientPid = -1, int32_t targetClientUid = -1, int32_t targetPriority = -1) { // Post the pushed atom int result = stats_write( MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED, requesterUid, requesterPriority, clientName.c_str(), noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClientUid, targetPriority); ALOGI("%s: Pushed MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED atom: " "Requester[pid(%d): uid(%d): priority(%d)] " "Codec: [%s] " "No of concurrent codecs: %d " "Reclaim Status: %d " "No of codecs reclaimed: %d " "Target[%d][pid(%d): uid(%d): priority(%d)] result: %d", __func__, callingPid, requesterUid, requesterPriority, clientName.c_str(), noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClientPid, targetClientUid, targetPriority, result); } void ResourceManagerMetrics::pushReclaimAtom(const ClientInfoParcel& clientInfo, const std::vector<int>& priorities, const std::vector<ClientInfo>& targetClients, Loading Loading @@ -485,33 +521,34 @@ void ResourceManagerMetrics::pushReclaimAtom(const ClientInfoParcel& clientInfo, MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED__RECLAIM_STATUS__RECLAIM_FAILED_RECLAIM_RESOURCES; } } if (targetClients.empty()) { // Push the reclaim atom to stats. pushReclaimStats(callingPid, requesterUid, requesterPriority, clientName, noOfConcurrentCodecs, reclaimStatus); return; } int32_t noOfCodecsReclaimed = targetClients.size(); int32_t targetIndex = 1; for (const ClientInfo& targetClient : targetClients) { int targetPriority = priorities[targetIndex]; // Post the pushed atom int result = stats_write( MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED, // Push the reclaim atom to stats. pushReclaimStats(callingPid, requesterUid, requesterPriority, clientName.c_str(), clientName, noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClient.mPid, targetClient.mUid, targetPriority); ALOGI("%s: Pushed MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED atom: " "Requester[pid(%d): uid(%d): priority(%d)] " "Codec: [%s] " "No of concurrent codecs: %d " "Reclaim Status: %d " "No of codecs reclaimed: %d " "Target[%d][pid(%d): uid(%d): priority(%d)] result: %d", __func__, callingPid, requesterUid, requesterPriority, clientName.c_str(), noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClient.mPid, targetClient.mUid, targetPriority, result); targetIndex++; } } Loading services/mediaresourcemanager/ResourceManagerMetrics.h +27 −2 Original line number Diff line number Diff line Loading @@ -96,7 +96,32 @@ struct PixelCount { }; // // ResourceManagerMetrics class that maintaines concurrent codec count based: // Resource Manager Metrics is designed to answer some of the questions like: // - What apps are causing reclaim and what apps are targeted (reclaimed from) in the process? // - which apps use the most codecs and the most codec memory? // - What is the % of total successful reclaims? // // Though, it's not in the context of this class, metrics should also answer: // - what % of codec errors are due to codec being reclaimed? // - What % of successful codec creation(start) requires codec reclaims? // - How often codec start fails even after successful reclaim? // // The metrics are collected to analyze and understand the codec resource usage // and use that information to help with: // - minimize the no of reclaims // - reduce the codec start delays by minimizing no of times we try to reclaim // - minimize the reclaim errors in codec records // // Success metrics for Resource Manager Service could be defined as: // - increase in sucecssful codec creation for the foreground apps // - reduce the number of reclaims for codecs // - reduce the time to create codec // // We would like to use this data to come up with a better resource management that would: // - increase the successful codec creation (for all kind of apps) // - decrease the codec errors due to resources // // This class that maintains concurrent codec counts based on: // // 1. # of concurrent active codecs (initialized, but aren't released yet) of given // implementation (by codec name) across the system. Loading @@ -111,7 +136,7 @@ struct PixelCount { // This should help with understanding the (video) memory usage per // application. // // class ResourceManagerMetrics { public: ResourceManagerMetrics(const sp<ProcessInfoInterface>& processInfo); Loading services/mediaresourcemanager/ResourceManagerService.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -586,18 +586,21 @@ Status ResourceManagerService::reclaimResource(const ClientInfoParcel& clientInf // Check if there are any resources to be reclaimed before processing. if (resources.empty()) { // Invalid reclaim request. So no need to log. return Status::ok(); } std::vector<ClientInfo> targetClients; if (!getTargetClients(clientInfo, resources, targetClients)) { // Nothing to reclaim from. if (getTargetClients(clientInfo, resources, targetClients)) { // Reclaim all the target clients. *_aidl_return = reclaimUnconditionallyFrom(targetClients); } else { // No clients to reclaim from. ALOGI("%s: There aren't any clients to reclaim from", __func__); return Status::ok(); // We need to log this failed reclaim as "no clients to reclaim from". targetClients.clear(); } *_aidl_return = reclaimUnconditionallyFrom(targetClients); // Log Reclaim Pushed Atom to statsd pushReclaimAtom(clientInfo, targetClients, *_aidl_return); Loading Loading
services/mediaresourcemanager/ResourceManagerMetrics.cpp +60 −23 Original line number Diff line number Diff line Loading @@ -447,6 +447,42 @@ void ResourceManagerMetrics::pushConcurrentUsageReport(int32_t pid, uid_t uid) { #endif } inline void pushReclaimStats(int32_t callingPid, int32_t requesterUid, int requesterPriority, const std::string& clientName, int32_t noOfConcurrentCodecs, int32_t reclaimStatus, int32_t noOfCodecsReclaimed = 0, int32_t targetIndex = -1, int32_t targetClientPid = -1, int32_t targetClientUid = -1, int32_t targetPriority = -1) { // Post the pushed atom int result = stats_write( MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED, requesterUid, requesterPriority, clientName.c_str(), noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClientUid, targetPriority); ALOGI("%s: Pushed MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED atom: " "Requester[pid(%d): uid(%d): priority(%d)] " "Codec: [%s] " "No of concurrent codecs: %d " "Reclaim Status: %d " "No of codecs reclaimed: %d " "Target[%d][pid(%d): uid(%d): priority(%d)] result: %d", __func__, callingPid, requesterUid, requesterPriority, clientName.c_str(), noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClientPid, targetClientUid, targetPriority, result); } void ResourceManagerMetrics::pushReclaimAtom(const ClientInfoParcel& clientInfo, const std::vector<int>& priorities, const std::vector<ClientInfo>& targetClients, Loading Loading @@ -485,33 +521,34 @@ void ResourceManagerMetrics::pushReclaimAtom(const ClientInfoParcel& clientInfo, MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED__RECLAIM_STATUS__RECLAIM_FAILED_RECLAIM_RESOURCES; } } if (targetClients.empty()) { // Push the reclaim atom to stats. pushReclaimStats(callingPid, requesterUid, requesterPriority, clientName, noOfConcurrentCodecs, reclaimStatus); return; } int32_t noOfCodecsReclaimed = targetClients.size(); int32_t targetIndex = 1; for (const ClientInfo& targetClient : targetClients) { int targetPriority = priorities[targetIndex]; // Post the pushed atom int result = stats_write( MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED, // Push the reclaim atom to stats. pushReclaimStats(callingPid, requesterUid, requesterPriority, clientName.c_str(), clientName, noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClient.mPid, targetClient.mUid, targetPriority); ALOGI("%s: Pushed MEDIA_CODEC_RECLAIM_REQUEST_COMPLETED atom: " "Requester[pid(%d): uid(%d): priority(%d)] " "Codec: [%s] " "No of concurrent codecs: %d " "Reclaim Status: %d " "No of codecs reclaimed: %d " "Target[%d][pid(%d): uid(%d): priority(%d)] result: %d", __func__, callingPid, requesterUid, requesterPriority, clientName.c_str(), noOfConcurrentCodecs, reclaimStatus, noOfCodecsReclaimed, targetIndex, targetClient.mPid, targetClient.mUid, targetPriority, result); targetIndex++; } } Loading
services/mediaresourcemanager/ResourceManagerMetrics.h +27 −2 Original line number Diff line number Diff line Loading @@ -96,7 +96,32 @@ struct PixelCount { }; // // ResourceManagerMetrics class that maintaines concurrent codec count based: // Resource Manager Metrics is designed to answer some of the questions like: // - What apps are causing reclaim and what apps are targeted (reclaimed from) in the process? // - which apps use the most codecs and the most codec memory? // - What is the % of total successful reclaims? // // Though, it's not in the context of this class, metrics should also answer: // - what % of codec errors are due to codec being reclaimed? // - What % of successful codec creation(start) requires codec reclaims? // - How often codec start fails even after successful reclaim? // // The metrics are collected to analyze and understand the codec resource usage // and use that information to help with: // - minimize the no of reclaims // - reduce the codec start delays by minimizing no of times we try to reclaim // - minimize the reclaim errors in codec records // // Success metrics for Resource Manager Service could be defined as: // - increase in sucecssful codec creation for the foreground apps // - reduce the number of reclaims for codecs // - reduce the time to create codec // // We would like to use this data to come up with a better resource management that would: // - increase the successful codec creation (for all kind of apps) // - decrease the codec errors due to resources // // This class that maintains concurrent codec counts based on: // // 1. # of concurrent active codecs (initialized, but aren't released yet) of given // implementation (by codec name) across the system. Loading @@ -111,7 +136,7 @@ struct PixelCount { // This should help with understanding the (video) memory usage per // application. // // class ResourceManagerMetrics { public: ResourceManagerMetrics(const sp<ProcessInfoInterface>& processInfo); Loading
services/mediaresourcemanager/ResourceManagerService.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -586,18 +586,21 @@ Status ResourceManagerService::reclaimResource(const ClientInfoParcel& clientInf // Check if there are any resources to be reclaimed before processing. if (resources.empty()) { // Invalid reclaim request. So no need to log. return Status::ok(); } std::vector<ClientInfo> targetClients; if (!getTargetClients(clientInfo, resources, targetClients)) { // Nothing to reclaim from. if (getTargetClients(clientInfo, resources, targetClients)) { // Reclaim all the target clients. *_aidl_return = reclaimUnconditionallyFrom(targetClients); } else { // No clients to reclaim from. ALOGI("%s: There aren't any clients to reclaim from", __func__); return Status::ok(); // We need to log this failed reclaim as "no clients to reclaim from". targetClients.clear(); } *_aidl_return = reclaimUnconditionallyFrom(targetClients); // Log Reclaim Pushed Atom to statsd pushReclaimAtom(clientInfo, targetClients, *_aidl_return); Loading