Skip to content

Commit 39f67c0

Browse files
AndroidMatt1Android (Google) Code Review
authored andcommitted
Merge "Add CPU/GPU_LOAD_SPIKE hints for one-off expensive workloads" into main
2 parents acc9438 + fd2b786 commit 39f67c0

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

include/android/performance_hint.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,31 @@ int APerformanceHint_notifyWorkloadReset(
358358
APerformanceHintSession* _Nonnull session,
359359
bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36);
360360

361+
/**
362+
* Informs the framework of an upcoming one-off expensive frame for a graphics pipeline
363+
* bound to this session. This frame will be treated as not representative of the workload as a
364+
* whole, and it will be discarded the purposes of load tracking. The user can specify
365+
* whether the workload spike is expected to be on the CPU, GPU, or both.
366+
*
367+
* Sending hints for both CPU and GPU counts as two separate hints for the purposes of the
368+
* rate limiter.
369+
*
370+
* @param cpu Indicates if the workload spike is expected to affect the CPU.
371+
* @param gpu Indicates if the workload spike is expected to affect the GPU.
372+
* @param debugName A required string used to identify this specific hint during
373+
* tracing. This debug string will only be held for the duration of the
374+
* method, and can be safely discarded after.
375+
*
376+
* @return 0 on success.
377+
* EINVAL if no hints were requested.
378+
* EBUSY if the hint was rate limited.
379+
* EPIPE if communication with the system service has failed.
380+
* ENOTSUP if the hint is not supported.
381+
*/
382+
int APerformanceHint_notifyWorkloadSpike(
383+
APerformanceHintSession* _Nonnull session,
384+
bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36);
385+
361386
/**
362387
* Associates a session with any {@link ASurfaceControl} or {@link ANativeWindow}
363388
* instances managed by this session.

include/private/performance_hint_private.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ enum SessionHint: int32_t {
7474
* baseline to prepare for an arbitrary load, and must wake up if inactive.
7575
*/
7676
GPU_LOAD_RESET = 7,
77+
78+
/**
79+
* This hint indicates an upcoming CPU workload that is abnormally large and
80+
* not representative of the workload. This should be used for rare, one-time
81+
* operations and should be ignored by any load tracking or session hysteresis.
82+
*/
83+
CPU_LOAD_SPIKE = 8,
84+
85+
/**
86+
* This hint indicates an upcoming GPU workload that is abnormally large and
87+
* not representative of the workload. This should be used for rare, one-time
88+
* operations and should be ignored by any load tracking or session hysteresis.
89+
*/
90+
GPU_LOAD_SPIKE = 9,
7791
};
7892

7993
// Allows access to PowerHAL's SessionTags without needing to import its AIDL

0 commit comments

Comments
 (0)