diff options
author | 2024-11-12 17:07:52 +0000 | |
---|---|---|
committer | 2024-11-12 17:07:52 +0000 | |
commit | 0bf29918e3569891da71c1adae76fb95f699dc3c (patch) | |
tree | b976d12a786cacc3c6594e14131989614f799dfc | |
parent | e05d6d80d81353f6eaa5fcc0bafae3eaf1c42b4e (diff) | |
parent | 122a1173634edcaf5b50e836185ae0c09c14ac2e (diff) |
Merge "Add public ADPF load hints with better rate limiter and hint batching" into main
-rw-r--r-- | include/android/performance_hint.h | 64 | ||||
-rw-r--r-- | include/private/performance_hint_private.h | 12 |
2 files changed, 75 insertions, 1 deletions
diff --git a/include/android/performance_hint.h b/include/android/performance_hint.h index 3486e9b1d7..976c7d6fb3 100644 --- a/include/android/performance_hint.h +++ b/include/android/performance_hint.h @@ -19,9 +19,23 @@ * * APerformanceHint allows apps to create performance hint sessions for groups * of threads, and provide hints to the system about the workload of those threads, - * to help the system more accurately allocate power for them. It is the NDK + * to help the system more accurately allocate resources for them. It is the NDK * counterpart to the Java PerformanceHintManager SDK API. * + * This API is intended for periodic workloads, such as frame production. Clients are + * expected to create an instance of APerformanceHintManager, create a session with + * that, and then set a target duration for the session. Then, they can report the actual + * work duration at the end of each cycle to inform the framework about how long those + * workloads are taking. The framework will then compare the actual durations to the target + * duration and attempt to help the client reach a steady state under the target. + * + * Unlike reportActualWorkDuration, the "notify..." hints are intended to be sent in + * advance of large changes in the workload, to prevent them from going over the target + * when there is a sudden, unforseen change. Their effects are intended to last for only + * one cycle, after which reportActualWorkDuration will have a chance to catch up. + * These hints should be used judiciously, only in cases where the workload is changing + * substantially. To enforce that, they are tracked using a per-app rate limiter to avoid + * excessive hinting and encourage clients to be mindful about when to send them. * @{ */ @@ -250,6 +264,54 @@ int APerformanceHint_reportActualWorkDuration2( AWorkDuration* _Nonnull workDuration) __INTRODUCED_IN(__ANDROID_API_V__); /** + * Informs the framework of an upcoming increase in the workload of a graphics pipeline + * bound to this session. The user can specify whether the increase is expected to be + * on the CPU, GPU, or both. + * + * Sending hints for both CPU and GPU counts as two separate hints for the purposes of the + * rate limiter. + * + * @param cpu Indicates if the workload increase is expected to affect the CPU. + * @param gpu Indicates if the workload increase is expected to affect the GPU. + * @param debugName A required string used to identify this specific hint during + * tracing. This debug string will only be held for the duration of the + * method, and can be safely discarded after. + * + * @return 0 on success. + * EINVAL if no hints were requested. + * EBUSY if the hint was rate limited. + * EPIPE if communication with the system service has failed. + * ENOTSUP if the hint is not supported. + */ +int APerformanceHint_notifyWorkloadIncrease( + APerformanceHintSession* _Nonnull session, + bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36); + +/** + * Informs the framework of an upcoming reset in the workload of a graphics pipeline + * bound to this session, or the imminent start of a new workload. The user can specify + * whether the reset is expected to affect the CPU, GPU, or both. + * + * Sending hints for both CPU and GPU counts as two separate hints for the purposes of the + * this load tracking. + * + * @param cpu Indicates if the workload reset is expected to affect the CPU. + * @param gpu Indicates if the workload reset is expected to affect the GPU. + * @param debugName A required string used to identify this specific hint during + * tracing. This debug string will only be held for the duration of the + * method, and can be safely discarded after. + * + * @return 0 on success. + * EINVAL if no hints were requested. + * EBUSY if the hint was rate limited. + * EPIPE if communication with the system service has failed. + * ENOTSUP if the hint is not supported. + */ +int APerformanceHint_notifyWorkloadReset( + APerformanceHintSession* _Nonnull session, + bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36); + +/** * Creates a new AWorkDuration. When the client finishes using {@link AWorkDuration}, it should * call {@link AWorkDuration_release()} to destroy {@link AWorkDuration} and release all resources * associated with it. diff --git a/include/private/performance_hint_private.h b/include/private/performance_hint_private.h index b7308c266c..3229e45203 100644 --- a/include/private/performance_hint_private.h +++ b/include/private/performance_hint_private.h @@ -114,6 +114,18 @@ APerformanceHintSession* APerformanceHint_createSessionInternal(APerformanceHint */ void APerformanceHint_setUseFMQForTesting(bool enabled); +/** + * Get the rate limiter properties for testing. + */ +void APerformanceHint_getRateLimiterPropertiesForTesting( + int32_t* maxLoadHintsPerInterval, int64_t* loadHintInterval); + +/* + * Forces the "new load hint" flag to be disabled for testing. + */ +void APerformanceHint_setUseNewLoadHintBehaviorForTesting(bool newBehavior); + + __END_DECLS #endif // ANDROID_PRIVATE_NATIVE_PERFORMANCE_HINT_PRIVATE_H |