Performance Hint Manager
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 resources for them.
Summary
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 "notifyWorkload..." 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.
        Enumerations | 
    |
|---|---|
        APerformanceHintFeature{
       | 
      enum This enum represents different aspects of performance hint functionality.   | 
    
        Typedefs | 
    |
|---|---|
        ANativeWindow
       | 
      typedefstruct ANativeWindow
         | 
    
        APerformanceHintFeature
       | 
      typedef This enum represents different aspects of performance hint functionality.   | 
    
        APerformanceHintManager
       | 
      typedefstruct APerformanceHintManager
        An opaque type representing a handle to a performance hint manager.   | 
    
        APerformanceHintSession
       | 
      typedefstruct APerformanceHintSession
        An opaque type representing a handle to a performance hint session.   | 
    
        ASessionCreationConfig
       | 
      typedefstruct ASessionCreationConfig
        An opaque type representing a handle to a performance hint session creation configuration.   | 
    
        ASurfaceControl
       | 
      typedefstruct ASurfaceControl
         | 
    
        AWorkDuration
       | 
      typedefstruct AWorkDuration
        AWorkDuration is an opaque type that represents the breakdown of the actual workload duration in each component internally.   | 
    
        Variables | 
    |
|---|---|
        checking
       | 
      
        int64_t Client side rate limiting is not use APerformanceHint_isFeatureSupported for support
         | 
    
        necessary
       | 
      
        int64_t Client side rate limiting is not
         | 
    
        Functions | 
    |
|---|---|
        APerformanceHint_borrowSessionFromJava(JNIEnv *_Nonnull env, jobject _Nonnull sessionObj)
       | 
      
        APerformanceHintSession *_Nonnull
        Return the APerformanceHintSession wrapped by a Java PerformanceHintManager.Session object.  
       | 
    
        APerformanceHint_closeSession(APerformanceHintSession *_Nonnull session)
       | 
      
        void
        Release the performance hint manager pointer acquired via APerformanceHint_createSession.  
       | 
    
        APerformanceHint_createSession(APerformanceHintManager *_Nonnull manager, const int32_t *_Nonnull threadIds, size_t size, int64_t initialTargetWorkDurationNanos)
       | 
      
        APerformanceHintSession *_Nullable
        Creates a session for the given set of threads and sets their initial target work duration.  
       | 
    
        APerformanceHint_createSessionUsingConfig(APerformanceHintManager *_Nonnull manager, ASessionCreationConfig *_Nonnull config, APerformanceHintSession *_Nullable *_Nonnull sessionOut)
       | 
      
        int
        Creates a session using arguments from a corresponding ASessionCreationConfig.  
       | 
    
        APerformanceHint_getManager()
       | 
      
        APerformanceHintManager *_Nullable
        Acquire an instance of the performance hint manager.  
       | 
    
        APerformanceHint_getMaxGraphicsPipelineThreadsCount(APerformanceHintManager *_Nonnull manager)
       | 
      
        int
        Get maximum number of graphics pipieline threads per-app for this device.  
       | 
    
        APerformanceHint_getPreferredUpdateRateNanos(APerformanceHintManager *_Nonnull manager) __DEPRECATED_IN(36
       | 
      int64_t
        Get preferred update rate information for this device.   | 
    
        APerformanceHint_isFeatureSupported(APerformanceHintFeature feature)
       | 
      
        bool
        Checks whether the device exposes support for a specific feature.  
       | 
    
        APerformanceHint_notifyWorkloadIncrease(APerformanceHintSession *_Nonnull session, bool cpu, bool gpu, const char *_Nonnull identifier)
       | 
      
        int
        Informs the framework of an upcoming increase in the workload of this session.  
       | 
    
        APerformanceHint_notifyWorkloadReset(APerformanceHintSession *_Nonnull session, bool cpu, bool gpu, const char *_Nonnull identifier)
       | 
      
        int
        Informs the framework that the workload associated with this session is about to start, or that it is about to completely change, and that the system should discard any assumptions about its characteristics inferred from previous activity.  
       | 
    
        APerformanceHint_notifyWorkloadSpike(APerformanceHintSession *_Nonnull session, bool cpu, bool gpu, const char *_Nonnull identifier)
       | 
      
        int
        Informs the framework of an upcoming one-off expensive workload cycle for a given session.  
       | 
    
        APerformanceHint_reportActualWorkDuration(APerformanceHintSession *_Nonnull session, int64_t actualDurationNanos)
       | 
      
        int
        Reports the actual duration for the last cycle of work.  
       | 
    
        APerformanceHint_reportActualWorkDuration2(APerformanceHintSession *_Nonnull session, AWorkDuration *_Nonnull workDuration)
       | 
      
        int
        Reports the durations for the last cycle of work.  
       | 
    
        APerformanceHint_setNativeSurfaces(APerformanceHintSession *_Nonnull session, ANativeWindow *_Nonnull *_Nullable nativeWindows, size_t nativeWindowsSize, ASurfaceControl *_Nonnull *_Nullable surfaceControls, size_t surfaceControlsSize)
       | 
      
        int
        Associates a session with any ASurfaceControl or ANativeWindow instances managed by this session.  
       | 
    
        APerformanceHint_setPreferPowerEfficiency(APerformanceHintSession *_Nonnull session, bool enabled)
       | 
      
        int
        This tells the session that these threads can be safely scheduled to prefer power efficiency over performance.  
       | 
    
        APerformanceHint_setThreads(APerformanceHintSession *_Nonnull session, const pid_t *_Nonnull threadIds, size_t size)
       | 
      
        int
        Set a list of threads to the performance hint session.  
       | 
    
        APerformanceHint_updateTargetWorkDuration(APerformanceHintSession *_Nonnull session, int64_t targetDurationNanos)
       | 
      
        int
        Updates this session's target duration for each cycle of work.  
       | 
    
        ASessionCreationConfig_create()
       | 
      
        ASessionCreationConfig *_Nonnull
         | 
    
        ASessionCreationConfig_release(ASessionCreationConfig *_Nonnull config)
       | 
      
        void
        Destroys a ASessionCreationConfig and frees all resources associated with it.  
       | 
    
        ASessionCreationConfig_setGraphicsPipeline(ASessionCreationConfig *_Nonnull config, bool enabled)
       | 
      
        void
        Sessions setting this hint are expected to time the critical path of graphics pipeline from end to end, with the total work duration representing the time from the start of frame production until the buffer is fully finished drawing.  
       | 
    
        ASessionCreationConfig_setNativeSurfaces(ASessionCreationConfig *_Nonnull config, ANativeWindow *_Nonnull *_Nullable nativeWindows, size_t nativeWindowsSize, ASurfaceControl *_Nonnull *_Nullable surfaceControls, size_t surfaceControlsSize)
       | 
      
        void
        Associates the created session with any ASurfaceControl or ANativeWindow instances it will be managing.  
       | 
    
        ASessionCreationConfig_setPreferPowerEfficiency(ASessionCreationConfig *_Nonnull config, bool enabled)
       | 
      
        void
        Sets whether power efficiency mode will be enabled for the session.  
       | 
    
        ASessionCreationConfig_setTargetWorkDurationNanos(ASessionCreationConfig *_Nonnull config, int64_t targetWorkDurationNanos)
       | 
      
        void
        Sets the initial target work duration in nanoseconds for the session to be created.  
       | 
    
        ASessionCreationConfig_setTids(ASessionCreationConfig *_Nonnull config, const pid_t *_Nonnull tids, size_t size)
       | 
      
        void
        Sets the tids to be associated with the session to be created.  
       | 
    
        ASessionCreationConfig_setUseAutoTiming(ASessionCreationConfig *_Nonnull config, bool cpu, bool gpu)
       | 
      
        void
        Enable automatic timing mode for sessions using the GRAPHICS_PIPELINE API with an attached surface.  
       | 
    
        AWorkDuration_create()
       | 
      
        AWorkDuration *_Nonnull
        Creates a new AWorkDuration.  
       | 
    
        AWorkDuration_release(AWorkDuration *_Nonnull aWorkDuration)
       | 
      
        void
        Destroys a AWorkDuration and frees all resources associated with it.  
       | 
    
        AWorkDuration_setActualCpuDurationNanos(AWorkDuration *_Nonnull aWorkDuration, int64_t actualCpuDurationNanos)
       | 
      
        void
        Sets the actual CPU work duration in nanoseconds.  
       | 
    
        AWorkDuration_setActualGpuDurationNanos(AWorkDuration *_Nonnull aWorkDuration, int64_t actualGpuDurationNanos)
       | 
      
        void
        Sets the actual GPU work duration in nanoseconds.  
       | 
    
        AWorkDuration_setActualTotalDurationNanos(AWorkDuration *_Nonnull aWorkDuration, int64_t actualTotalDurationNanos)
       | 
      
        void
        Sets the actual total work duration in nanoseconds.  
       | 
    
        AWorkDuration_setWorkPeriodStartTimestampNanos(AWorkDuration *_Nonnull aWorkDuration, int64_t workPeriodStartTimestampNanos)
       | 
      
        void
        Sets the work period start timestamp in nanoseconds.  
       | 
    
Enumerations
APerformanceHintFeature
Declared inandroid/performance_hint.h
    APerformanceHintFeature
This enum represents different aspects of performance hint functionality.
These can be passed to APerformanceHint_isFeatureSupported to determine whether the device exposes support for that feature.
Some of these features will not expose failure to the client if used when unsupported, to prevent the client from needing to worry about handling different logic for each possible support configuration. The exception to this is features with important user-facing side effects, such as APERF_HINT_AUTO_CPU and APERF_HINT_AUTO_GPU modes which expect the client not to report durations while they are active.
| Properties | |
|---|---|
            APERF_HINT_AUTO_CPU
           | 
          
             This value represents the automatic CPU timing feature, as exposed by ASessionCreationConfig_setUseAutoTiming.  | 
        
            APERF_HINT_AUTO_GPU
           | 
          
             This value represents the automatic GPU timing feature, as exposed by ASessionCreationConfig_setUseAutoTiming.  | 
        
            APERF_HINT_GRAPHICS_PIPELINE
           | 
          
             This value represents the "graphics pipeline" mode, as exposed by ASessionCreationConfig_setGraphicsPipeline.  | 
        
            APERF_HINT_POWER_EFFICIENCY
           | 
          
             This value represents the power efficiency mode, as exposed by ASessionCreationConfig_setPreferPowerEfficiency and APerformanceHint_setPreferPowerEfficiency.  | 
        
            APERF_HINT_SESSIONS
           | 
          
             This value represents all APerformanceHintSession functionality. Using the Performance Hint API at all if this is not enabled will likely result in either APerformanceHintManager or APerformanceHintSession failing to create, or the session having little to no benefit even if creation succeeds.  | 
        
            APERF_HINT_SURFACE_BINDING
           | 
          
             This value the ability for sessions to bind to surfaces using APerformanceHint_setNativeSurfaces or ASessionCreationConfig_setNativeSurfaces.  | 
        
Typedefs
APerformanceHintFeature
Declared inandroid/performance_hint.h
    enum APerformanceHintFeature APerformanceHintFeature
This enum represents different aspects of performance hint functionality.
These can be passed to APerformanceHint_isFeatureSupported to determine whether the device exposes support for that feature.
Some of these features will not expose failure to the client if used when unsupported, to prevent the client from needing to worry about handling different logic for each possible support configuration. The exception to this is features with important user-facing side effects, such as APERF_HINT_AUTO_CPU and APERF_HINT_AUTO_GPU modes which expect the client not to report durations while they are active.
APerformanceHintManager
Declared inandroid/performance_hint.h
    struct APerformanceHintManager APerformanceHintManager
An opaque type representing a handle to a performance hint manager.
To use:
- Obtain the performance hint manager instance by calling APerformanceHint_getManager function.
 - Create an APerformanceHintSession with APerformanceHint_createSession.
 - Get the preferred update rate in nanoseconds with APerformanceHint_getPreferredUpdateRateNanos.
 
APerformanceHintSession
Declared inandroid/performance_hint.h
    struct APerformanceHintSession APerformanceHintSession
An opaque type representing a handle to a performance hint session.
A session can only be acquired from a APerformanceHintManager with APerformanceHint_createSession or APerformanceHint_createSessionUsingConfig. It must be freed with APerformanceHint_closeSession after use.
A Session represents a group of threads with an inter-related workload such that hints for their performance should be considered as a unit. The threads in a given session should be long-lived and not created or destroyed dynamically.
The work duration API can be used with periodic workloads to dynamically adjust thread performance and keep the work on schedule while optimizing the available power budget. When using the work duration API, the starting target duration should be specified while creating the session, and can later be adjusted with APerformanceHint_updateTargetWorkDuration. While using the work duration API, the client is expected to call APerformanceHint_reportActualWorkDuration each cycle to report the actual time taken to complete to the system.
Note, methods of APerformanceHintSession_* are not thread safe so callers must ensure thread safety.
All timings should be from std::chrono::steady_clock or clock_gettime(CLOCK_MONOTONIC, ...)
ASessionCreationConfig
Declared inandroid/performance_hint.h
    struct ASessionCreationConfig ASessionCreationConfig
An opaque type representing a handle to a performance hint session creation configuration.
It is consumed by APerformanceHint_createSessionUsingConfig.
A session creation config encapsulates the required information for creating a session. The only mandatory parameter is the set of TIDs, set using ASessionCreationConfig_setTids. Only parameters relevant to the session need to be set, and any unspecified functionality will be treated as unused on the session. Configurations without a valid set of TIDs, or which try to enable automatic timing without the graphics pipeline mode, are considered invalid.
The caller may reuse this object and modify the settings in it to create additional sessions.
ASurfaceControl
Declared inandroid/performance_hint.h
    struct ASurfaceControl ASurfaceControl
AWorkDuration
Declared inandroid/performance_hint.h
    struct AWorkDuration AWorkDuration
AWorkDuration is an opaque type that represents the breakdown of the actual workload duration in each component internally.
A new AWorkDuration can be obtained using AWorkDuration_create(), when the client finishes using AWorkDuration, AWorkDuration_release() must be called to destroy and free up the resources associated with AWorkDuration.
This file provides a set of functions to allow clients to set the measured work duration of each component on AWorkDuration.
Variables
checking
Declared inandroid/performance_hint.h
    int64_t Client side rate limiting is not use APerformanceHint_isFeatureSupported for support checking
necessary
Declared inandroid/performance_hint.h
    int64_t Client side rate limiting is not necessary
Functions
APerformanceHint_borrowSessionFromJava
Declared inandroid/performance_hint.h
    APerformanceHintSession *_Nonnull APerformanceHint_borrowSessionFromJava( JNIEnv *_Nonnull env, jobject _Nonnull sessionObj )
Return the APerformanceHintSession wrapped by a Java PerformanceHintManager.Session object.
The Java session maintains ownership over the wrapped native session, so it cannot be closed using APerformanceHint_closeSession. The return value is valid until the Java object containing this value dies.
The returned pointer is intended to be used by JNI calls to access native performance APIs using a Java hint session wrapper, and then immediately discarded. Using the pointer after the death of the Java container results in undefined behavior.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||
| Returns | 
               A pointer to the APerformanceHintManager that backs the Java Session.  
             | 
          
APerformanceHint_closeSession
Declared inandroid/performance_hint.h
    void APerformanceHint_closeSession( APerformanceHintSession *_Nonnull session )
Release the performance hint manager pointer acquired via APerformanceHint_createSession.
This cannot be used to close a Java PerformanceHintManager.Session, as its lifecycle is tied to the object in the SDK.
| Details | |||
|---|---|---|---|
| Parameters | 
              
  | 
          
APerformanceHint_createSession
Declared inandroid/performance_hint.h
    APerformanceHintSession *_Nullable APerformanceHint_createSession( APerformanceHintManager *_Nonnull manager, const int32_t *_Nonnull threadIds, size_t size, int64_t initialTargetWorkDurationNanos )
Creates a session for the given set of threads and sets their initial target work duration.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||||||
| Returns | 
               APerformanceHintSession pointer on success, nullptr on failure.  
             | 
          
APerformanceHint_createSessionUsingConfig
Declared inandroid/performance_hint.h
    int APerformanceHint_createSessionUsingConfig( APerformanceHintManager *_Nonnull manager, ASessionCreationConfig *_Nonnull config, APerformanceHintSession *_Nullable *_Nonnull sessionOut )
Creates a session using arguments from a corresponding ASessionCreationConfig.
Note: when using graphics pipeline mode, using too many cumulative graphics pipeline threads is not a failure and will still create a session, but it will cause all graphics pipeline sessions to have undefined behavior and the method will return EBUSY.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||||
| Returns | 
               0 on success. EINVAL if the creation config is in an invalid state. EPIPE if communication failed. ENOTSUP if hint sessions are not supported, or if auto timing is enabled but unsupported. EBUSY if too many graphics pipeline threads are passed.  
             | 
          
APerformanceHint_getManager
Declared inandroid/performance_hint.h
    APerformanceHintManager *_Nullable APerformanceHint_getManager()
Acquire an instance of the performance hint manager.
| Details | |
|---|---|
| Returns | 
               APerformanceHintManager instance on success, nullptr on failure.  
             | 
          
APerformanceHint_getMaxGraphicsPipelineThreadsCount
Declared inandroid/performance_hint.h
    int APerformanceHint_getMaxGraphicsPipelineThreadsCount( APerformanceHintManager *_Nonnull manager )
Get maximum number of graphics pipieline threads per-app for this device.
| Details | |||
|---|---|---|---|
| Parameters | 
              
  | 
          ||
| Returns | 
               the maximum number of graphics pipeline threads supported by device.  
             | 
          
APerformanceHint_getPreferredUpdateRateNanos
Declared inandroid/performance_hint.h
    int64_t APerformanceHint_getPreferredUpdateRateNanos( APerformanceHintManager *_Nonnull manager ) __DEPRECATED_IN(36
Get preferred update rate information for this device.
Deprecated. Client side rate limiting is not necessary, rate limiting is handled in the framework. If you were using this to check for hint session support, please use APerformanceHint_isFeatureSupported instead.
| Details | |||
|---|---|---|---|
| Parameters | 
              
  | 
          ||
| Returns | 
               the preferred update rate supported by device software.  
             | 
          
APerformanceHint_isFeatureSupported
Declared inandroid/performance_hint.h
    bool APerformanceHint_isFeatureSupported( APerformanceHintFeature feature )
Checks whether the device exposes support for a specific feature.
| Details | |||
|---|---|---|---|
| Parameters | 
              
  | 
          ||
| Returns | 
               false if unsupported, true if supported.  
             | 
          
APerformanceHint_notifyWorkloadIncrease
Declared inandroid/performance_hint.h
    int APerformanceHint_notifyWorkloadIncrease( APerformanceHintSession *_Nonnull session, bool cpu, bool gpu, const char *_Nonnull identifier )
Informs the framework of an upcoming increase in the workload of this session.
The user can specify whether the increase is expected to be on the CPU, GPU, or both.
These hints should be sent shortly before the start of the cycle where the workload is going to change, or as early as possible during that cycle for maximum effect. Hints sent towards the end of the cycle may be interpreted as applying to the next cycle. Any unsupported hints will be silently dropped, to avoid the need for excessive support checking each time they are sent, and sending a hint for both CPU and GPU will count as two separate hints for the rate limiter. These hints should not be sent repeatedly for an ongoing expensive workload, as workload time reporting is intended to handle this.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||||||
| Returns | 
               0 on success. EBUSY if the hint was rate limited. EPIPE if communication with the system service has failed.  
             | 
          
APerformanceHint_notifyWorkloadReset
Declared inandroid/performance_hint.h
    int APerformanceHint_notifyWorkloadReset( APerformanceHintSession *_Nonnull session, bool cpu, bool gpu, const char *_Nonnull identifier )
Informs the framework that the workload associated with this session is about to start, or that it is about to completely change, and that the system should discard any assumptions about its characteristics inferred from previous activity.
The user can specify whether the reset is expected to affect the CPU, GPU, or both.
These hints should be sent shortly before the start of the cycle where the workload is going to change, or as early as possible during that cycle for maximum effect. Hints sent towards the end of the cycle may be interpreted as applying to the next cycle. Any unsupported hints will be silently dropped, to avoid the need for excessive support checking each time they are sent, and sending a hint for both CPU and GPU will count as two separate hints for the rate limiter. These hints should not be sent repeatedly for an ongoing expensive workload, as workload time reporting is intended to handle this.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||||||
| Returns | 
               0 on success. EBUSY if the hint was rate limited. EPIPE if communication with the system service has failed.  
             | 
          
APerformanceHint_notifyWorkloadSpike
Declared inandroid/performance_hint.h
    int APerformanceHint_notifyWorkloadSpike( APerformanceHintSession *_Nonnull session, bool cpu, bool gpu, const char *_Nonnull identifier )
Informs the framework of an upcoming one-off expensive workload cycle for a given session.
This cycle will be treated as not representative of the workload as a whole, and it will be discarded the purposes of load tracking. The user can specify whether the workload spike is expected to be on the CPU, GPU, or both.
These hints should be sent shortly before the start of the cycle where the workload is going to change, or as early as possible during that cycle for maximum effect. Hints sent towards the end of the cycle may be interpreted as applying to the next cycle. Any unsupported hints will be silently dropped, to avoid the need for excessive support checking each time they are sent, and sending a hint for both CPU and GPU will count as two separate hints for the rate limiter. These hints should not be sent repeatedly for an ongoing expensive workload, as workload time reporting is intended to handle this.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||||||
| Returns | 
               0 on success. EBUSY if the hint was rate limited. EPIPE if communication with the system service has failed.  
             | 
          
APerformanceHint_reportActualWorkDuration
Declared inandroid/performance_hint.h
    int APerformanceHint_reportActualWorkDuration( APerformanceHintSession *_Nonnull session, int64_t actualDurationNanos )
Reports the actual duration for the last cycle of work.
The system will attempt to adjust the scheduling and performance of the threads within the thread group to bring the actual duration close to the target duration.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||
| Returns | 
               0 on success. EINVAL if actualDurationNanos is not positive or the target it not positive. EPIPE if communication with the system service has failed.  
             | 
          
APerformanceHint_reportActualWorkDuration2
Declared inandroid/performance_hint.h
    int APerformanceHint_reportActualWorkDuration2( APerformanceHintSession *_Nonnull session, AWorkDuration *_Nonnull workDuration )
Reports the durations for the last cycle of work.
The system will attempt to adjust the scheduling and performance of the threads within the thread group to bring the actual duration close to the target duration.
The work period start timestamp and actual total duration must be greater than zero.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
The actual CPU and GPU durations must be greater than or equal to zero, and at least one of them must be greater than zero. When one of them is equal to zero, it means that type of work was not measured for this workload.
| Details | |
|---|---|
| Returns | 
               0 on success. EINVAL if any duration is an invalid number. EPIPE if communication with the system service has failed.  
             | 
          
APerformanceHint_setNativeSurfaces
Declared inandroid/performance_hint.h
    int APerformanceHint_setNativeSurfaces( APerformanceHintSession *_Nonnull session, ANativeWindow *_Nonnull *_Nullable nativeWindows, size_t nativeWindowsSize, ASurfaceControl *_Nonnull *_Nullable surfaceControls, size_t surfaceControlsSize )
Associates a session with any ASurfaceControl or ANativeWindow instances managed by this session.
Any previously associated objects that are not passed in again lose their association. Invalid or dead instances are ignored, and passing both lists as null drops all current associations.
This method is primarily intended for sessions that manage the timing of an entire graphics pipeline end-to-end for frame pacing, such as those using the ASessionCreationConfig_setGraphicsPipeline API. However, any session directly or indirectly managing a graphics pipeline should still associate themselves with directly relevant ASurfaceControl or ANativeWindow instances for better optimization. Additionally, if the surface associated with a session changes, this method should be called again to re-create the association.
To see any benefit from this method, the client must make sure they are updating the frame rate of attached surfaces using methods such as ANativeWindow_setFrameRate, or by updating any associated ASurfaceControls with transactions that have {ASurfaceTransaction_setFrameRate}.
| Details | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||||||||
| Returns | 
               0 on success. EPIPE if communication has failed. ENOTSUP if this is not supported on the device.  
             | 
          
APerformanceHint_setPreferPowerEfficiency
Declared inandroid/performance_hint.h
    int APerformanceHint_setPreferPowerEfficiency( APerformanceHintSession *_Nonnull session, bool enabled )
This tells the session that these threads can be safely scheduled to prefer power efficiency over performance.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||
| Returns | 
               0 on success. EPIPE if communication with the system service has failed.  
             | 
          
APerformanceHint_setThreads
Declared inandroid/performance_hint.h
    int APerformanceHint_setThreads( APerformanceHintSession *_Nonnull session, const pid_t *_Nonnull threadIds, size_t size )
Set a list of threads to the performance hint session.
This operation will replace the current list of threads with the given list of threads.
Note: when using a session with the graphics pipeline mode enabled, using too many cumulative graphics pipeline threads is not a failure, but it will cause all graphics pipeline sessions to have undefined behavior and the method will return EBUSY.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||||
| Returns | 
               0 on success. EINVAL if the list of thread ids is empty or if any of the thread ids are not part of the thread group. EPIPE if communication with the system service has failed. EPERM if any thread id doesn't belong to the application. EBUSY if too many graphics pipeline threads were passed.  
             | 
          
APerformanceHint_updateTargetWorkDuration
Declared inandroid/performance_hint.h
    int APerformanceHint_updateTargetWorkDuration( APerformanceHintSession *_Nonnull session, int64_t targetDurationNanos )
Updates this session's target duration for each cycle of work.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          ||||
| Returns | 
               0 on success. EINVAL if targetDurationNanos is less than zero. EPIPE if communication with the system service has failed.  
             | 
          
ASessionCreationConfig_create
Declared inandroid/performance_hint.h
    ASessionCreationConfig *_Nonnull ASessionCreationConfig_create()
ASessionCreationConfig_release
Declared inandroid/performance_hint.h
    void ASessionCreationConfig_release( ASessionCreationConfig *_Nonnull config )
Destroys a ASessionCreationConfig and frees all resources associated with it.
| Details | |||
|---|---|---|---|
| Parameters | 
              
  | 
          
ASessionCreationConfig_setGraphicsPipeline
Declared inandroid/performance_hint.h
    void ASessionCreationConfig_setGraphicsPipeline( ASessionCreationConfig *_Nonnull config, bool enabled )
Sessions setting this hint are expected to time the critical path of graphics pipeline from end to end, with the total work duration representing the time from the start of frame production until the buffer is fully finished drawing.
It should include any threads on the critical path of that pipeline, up to a limit accessible from APerformanceHint_getMaxGraphicsPipelineThreadsCount().
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
ASessionCreationConfig_setNativeSurfaces
Declared inandroid/performance_hint.h
    void ASessionCreationConfig_setNativeSurfaces( ASessionCreationConfig *_Nonnull config, ANativeWindow *_Nonnull *_Nullable nativeWindows, size_t nativeWindowsSize, ASurfaceControl *_Nonnull *_Nullable surfaceControls, size_t surfaceControlsSize )
Associates the created session with any ASurfaceControl or ANativeWindow instances it will be managing.
Invalid or dead instances are ignored.
This method is primarily intended for sessions that manage the timing of an entire graphics pipeline end-to-end for frame pacing, such as those using the ASessionCreationConfig_setGraphicsPipeline API. However, any session directly or indirectly managing a graphics pipeline should still associate themselves with directly relevant ASurfaceControl or ANativeWindow instances for better optimization. Additionally, if the surface associated with a session changes, this method should be called again to re-create the association.
To see any benefit from this method, the client must make sure they are updating the frame rate of attached surfaces using methods such as ANativeWindow_setFrameRate, or by updating any associated ASurfaceControls with transactions that have {ASurfaceTransaction_setFrameRate}.
| Details | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
ASessionCreationConfig_setPreferPowerEfficiency
Declared inandroid/performance_hint.h
    void ASessionCreationConfig_setPreferPowerEfficiency( ASessionCreationConfig *_Nonnull config, bool enabled )
Sets whether power efficiency mode will be enabled for the session.
This tells the session that these threads can be safely scheduled to prefer power efficiency over performance.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
ASessionCreationConfig_setTargetWorkDurationNanos
Declared inandroid/performance_hint.h
    void ASessionCreationConfig_setTargetWorkDurationNanos( ASessionCreationConfig *_Nonnull config, int64_t targetWorkDurationNanos )
Sets the initial target work duration in nanoseconds for the session to be created.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
ASessionCreationConfig_setTids
Declared inandroid/performance_hint.h
    void ASessionCreationConfig_setTids( ASessionCreationConfig *_Nonnull config, const pid_t *_Nonnull tids, size_t size )
Sets the tids to be associated with the session to be created.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
ASessionCreationConfig_setUseAutoTiming
Declared inandroid/performance_hint.h
    void ASessionCreationConfig_setUseAutoTiming( ASessionCreationConfig *_Nonnull config, bool cpu, bool gpu )
Enable automatic timing mode for sessions using the GRAPHICS_PIPELINE API with an attached surface.
In this mode, sessions do not need to report timing data for the CPU, GPU, or both depending on the configuration. To use this mode, sessions should set a native surface using {}, enable graphics pipeline mode with ASessionCreationConfig_setGraphicsPipeline(), and then call this method to set whether automatic timing is desired for the CPU, GPU, or both. Trying to enable this without also enabling the graphics pipeline mode will cause session creation to fail.
It is still be beneficial to set an accurate target time, as this may help determine timing information for some workloads where there is less information available from the framework, such as games. Additionally, reported CPU durations will be ignored while automatic CPU timing is enabled, and similarly GPU durations will be ignored when automatic GPU timing is enabled. When both are enabled, the entire APerformanceHint_reportActualWorkDuration call will be ignored, and the session will be managed completely automatically.
If the client is manually controlling their frame rate for those surfaces, then they must make sure they are updating the frame rate with ANativeWindow_setFrameRate, or updating any associated ASurfaceControls with transactions that have {ASurfaceTransaction_setFrameRate} set.
The user of this API should ensure this feature is supported by checking APERF_HINT_AUTO_CPU and APERF_HINT_AUTO_GPU with APerformanceHint_isFeatureSupported and falling back to manual timing if it is not. Trying to use automatic timing when it is unsupported will cause session creation to fail.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
AWorkDuration_create
Declared inandroid/performance_hint.h
    AWorkDuration *_Nonnull AWorkDuration_create()
Creates a new AWorkDuration.
When the client finishes using AWorkDuration, it should call AWorkDuration_release() to destroy AWorkDuration and release all resources associated with it.
| Details | |
|---|---|
| Returns | 
               AWorkDuration pointer.  
             | 
          
AWorkDuration_release
Declared inandroid/performance_hint.h
    void AWorkDuration_release( AWorkDuration *_Nonnull aWorkDuration )
Destroys a AWorkDuration and frees all resources associated with it.
| Details | |||
|---|---|---|---|
| Parameters | 
              
  | 
          
AWorkDuration_setActualCpuDurationNanos
Declared inandroid/performance_hint.h
    void AWorkDuration_setActualCpuDurationNanos( AWorkDuration *_Nonnull aWorkDuration, int64_t actualCpuDurationNanos )
Sets the actual CPU work duration in nanoseconds.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
AWorkDuration_setActualGpuDurationNanos
Declared inandroid/performance_hint.h
    void AWorkDuration_setActualGpuDurationNanos( AWorkDuration *_Nonnull aWorkDuration, int64_t actualGpuDurationNanos )
Sets the actual GPU work duration in nanoseconds.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
AWorkDuration_setActualTotalDurationNanos
Declared inandroid/performance_hint.h
    void AWorkDuration_setActualTotalDurationNanos( AWorkDuration *_Nonnull aWorkDuration, int64_t actualTotalDurationNanos )
Sets the actual total work duration in nanoseconds.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  | 
          
AWorkDuration_setWorkPeriodStartTimestampNanos
Declared inandroid/performance_hint.h
    void AWorkDuration_setWorkPeriodStartTimestampNanos( AWorkDuration *_Nonnull aWorkDuration, int64_t workPeriodStartTimestampNanos )
Sets the work period start timestamp in nanoseconds.
| Details | |||||
|---|---|---|---|---|---|
| Parameters | 
              
  |