implementing concurrent codec metrics
Following changes are made in this CL:
- extend IResourceManagerService interface to allow:
- notify create/start/stop of codecs
- implement concurrent codec metrics with different
buckets (such as different resolution, codec type)
for all the application/process and for the system.
- push the codec concurrency metrics to statsd
- move all metrics to a different class
- update codec reported metrics with codec id
Bug: 265488359
Test: atest cts/tests/media/misc/src/android/media/misc/cts/ResourceManagerTest.java
/data/nativetest64/ResourceManagerService_test/ResourceManagerService_test
/data/nativetest64/ResourceObserverService_test/ResourceObserverService_test
refactoring CL. Existing unit tests still pass.
Merged-In: Ibaa1fb9607e486f2eb79bf02d79c630e09d62b4a
Change-Id: Ibaa1fb9607e486f2eb79bf02d79c630e09d62b4a
diff --git a/services/mediaresourcemanager/ResourceManagerService.h b/services/mediaresourcemanager/ResourceManagerService.h
index 0016a19..b9756ae 100644
--- a/services/mediaresourcemanager/ResourceManagerService.h
+++ b/services/mediaresourcemanager/ResourceManagerService.h
@@ -39,6 +39,7 @@
class ResourceObserverService;
class ServiceLog;
struct ProcessInfoInterface;
+class ResourceManagerMetrics;
using Status = ::ndk::ScopedAStatus;
using ::aidl::android::media::IResourceManagerClient;
@@ -46,6 +47,7 @@
using ::aidl::android::media::MediaResourceParcel;
using ::aidl::android::media::MediaResourcePolicyParcel;
using ::aidl::android::media::ClientInfoParcel;
+using ::aidl::android::media::ClientConfigParcel;
typedef std::map<std::tuple<
MediaResource::Type, MediaResource::SubType, std::vector<uint8_t>>,
@@ -61,6 +63,7 @@
bool pendingRemoval{false};
};
+// vector of <PID, UID>
typedef std::vector<std::pair<int32_t, uid_t>> PidUidVector;
// TODO: convert these to std::map
@@ -118,6 +121,12 @@
Status removeResource(const ClientInfoParcel& clientInfo, bool checkValid);
+ Status notifyClientCreated(const ClientInfoParcel& clientInfo) override;
+
+ Status notifyClientStarted(const ClientConfigParcel& clientConfig) override;
+
+ Status notifyClientStopped(const ClientConfigParcel& clientConfig) override;
+
private:
friend class ResourceManagerServiceTest;
friend class DeathNotifier;
@@ -182,15 +191,15 @@
void removeCookieAndUnlink_l(const std::shared_ptr<IResourceManagerClient>& client,
uintptr_t cookie);
- // To increase/decrease the number of instances of a given resource
- // associated with a client.
- void increaseResourceInstanceCount(int64_t clientId, const std::string& name);
- void decreaseResourceInstanceCount(int64_t clientId, const std::string& name);
-
void pushReclaimAtom(const ClientInfoParcel& clientInfo,
const Vector<std::shared_ptr<IResourceManagerClient>>& clients,
const PidUidVector& idList, bool reclaimed);
+ // Get the peak concurrent pixel count (associated with the video codecs) for the process.
+ long getPeakConcurrentPixelCount(int pid) const;
+ // Get the current concurrent pixel count (associated with the video codecs) for the process.
+ long getCurrentConcurrentPixelCount(int pid) const;
+
mutable Mutex mLock;
sp<ProcessInfoInterface> mProcessInfo;
sp<SystemCallbackInterface> mSystemCB;
@@ -211,11 +220,7 @@
static std::map<uintptr_t, sp<DeathNotifier> > sCookieToDeathNotifierMap
GUARDED_BY(sCookieLock);
std::shared_ptr<ResourceObserverService> mObserverService;
-
- // List of active clients
- std::set<int64_t> mClientIdSet;
- // Map of resources (name) and number of concurrent instances
- std::map<std::string, int> mConcurrentResourceCountMap;
+ std::unique_ptr<ResourceManagerMetrics> mResourceManagerMetrics;
};
// ----------------------------------------------------------------------------