Home | History | Annotate | Download | only in power
      1 page.title=Performance Management
      2 @jd:body
      3 
      4 <!--
      5     Copyright 2016 The Android Open Source Project
      6 
      7     Licensed under the Apache License, Version 2.0 (the "License");
      8     you may not use this file except in compliance with the License.
      9     You may obtain a copy of the License at
     10 
     11         http://www.apache.org/licenses/LICENSE-2.0
     12 
     13     Unless required by applicable law or agreed to in writing, software
     14     distributed under the License is distributed on an "AS IS" BASIS,
     15     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16     See the License for the specific language governing permissions and
     17     limitations under the License.
     18 -->
     19 <div id="qv-wrapper">
     20   <div id="qv">
     21     <h2>In this document</h2>
     22     <ol id="auto-toc"></ol>
     23   </div>
     24 </div>
     25 
     26 <p>Managing the power and performance of Android devices can help ensure
     27 applications run consistently and smoothly on a wide range of hardware. In
     28 Android 7.0, OEMs can implement support for sustained performance hints that
     29 enable apps to maintain a consistent device performance and specify an exclusive
     30 core to improve performance for CPU-intensive, foreground applications.</p>
     31 
     32 <h2 id=sustained_performance>Sustained performance</h2>
     33 <p>For long-running applications (games, camera, RenderScript, audio
     34 processing), performance can vary dramatically as device temperature limits are
     35 reached and system on chip (SoC) engines are throttled. App developers creating
     36 high-performance, long-running apps are limited because the capabilities of the
     37 underlying platform are a moving target when the device begins to heat up.</p>
     38 
     39 <p>To address these limitations, Android 7.0 includes support for sustained
     40 performance, enabling OEMs to provide hints on device performance capabilities
     41 for long-running applications. App developers can use these hints to tune
     42 applications for a predictable, consistent level of device performance over long
     43 periods of time.</p>
     44 
     45 <h3 id=architecture>Architecture</h3>
     46 <p>An Android application can request the platform to enter a sustained
     47 performance mode where the Android device can keep a consistent level of
     48 performance for prolonged periods of time.</p>
     49 
     50 <p><img src="../images/power_sustained_perf.png"></p>
     51 <p class="img-caption"><strong>Figure 1.</strong> Sustained performance mode
     52 architecture</p>
     53 
     54 <h3 id=implementation>Implementation</h3>
     55 <p>To support sustained performance in Android 7.0, OEMs must:</p>
     56 <ul>
     57 <li>Make device-specific changes to the power HAL to either lock the maximum
     58 CPU/GPU frequencies <strong>or</strong> perform other optimizations to prevent
     59 thermal throttling.</li>
     60 <li>Implement the new hint <code>POWER_HINT_SUSTAINED_PERFORMANCE</code> in
     61 power HAL.</li>
     62 <li>Declare support by returning TRUE through the
     63 <code>isSustainedPerformanceModeSupported()</code> API.</li>
     64 <li>Implement <code>Window.setSustainedPerformanceMode</code>.</li>
     65 </ul>
     66 
     67 <p>In the Nexus reference implementation, the power hint caps the
     68 maximum frequencies of the CPU and GPU at the highest sustainable levels. Keep
     69 in mind that lowering the MAX bar in CPU/GPU frequency will lower the frame
     70 rate, but this lower rate is preferred in this mode due to its sustainability.
     71 For example, a device using normal max clocks might be able to render at 60
     72 FPS for a few minutes, but after the device heats up,  it may throttle to 30 FPS
     73 by the end of 30 minutes. When using sustained mode, the device can, for
     74 example, render consistently at 45 FPS for the entire 30 minutes. The goal is a
     75 frame rate when using the mode that is as high (or higher) than the frame rate
     76 when not using the mode, and consistent over time so that developers don't have
     77 to chase a moving target.</p>
     78 <p>We strongly recommend implementing sustained mode such that the device
     79 achieves the highest possible sustained performancenot just the minimum values
     80 required to pass the test (e.g. choose the highest possible MAX frequency caps
     81 that do not cause the device to thermally throttle over time).</p>
     82 
     83 <p class="note"><strong>Note</strong>: Capping MAX clock rates is not required
     84 to implement sustained mode.</p>
     85 
     86 <h3 id=validation>Validation</h3>
     87 <p>OEMs can use a new Android 7.0 CTS test to verify their implementation of the
     88 sustained performance API. The test runs a workload for approximately 30 minutes
     89 and benchmarks the performance with and without sustained mode enabled:</p>
     90 <ul>
     91 <li>With sustained mode enabled, the frame rate must remain relatively constant
     92 (test measures the percentage of change in frame rate over time and requires a
     93 &lt;5% change).</li>
     94 <li>With sustained mode enabled, the frame rate must not be lower than the frame
     95 rate at the end of 30 minutes with the mode disabled.</li>
     96 </ul>
     97 <p>In addition, you can manually test your implementation with several CPU- and
     98 GPU-intensive workloads to ensure the device does not thermally throttle after
     99 30 minutes of use. In internal testing, we used sample workloads including
    100 games and benchmarking apps (e.g.
    101 <a href="https://gfxbench.com/result.jsp">gfxbench</a>).</p>
    102 
    103 <h2 id=exclusive_core>Exclusive cores</h2>
    104 <p>For CPU-intensive, time-sensitive workloads, getting preempted by another
    105 thread can be the difference between making frame deadlines or not. For apps
    106 that have strict latency and frame rate requirements (such as audio or virtual
    107 reality apps), having an exclusive CPU core can guarantee an acceptable level of
    108 performance.</p>
    109 <p>Devices running Android 7.0 can now reserve one core explicitly for the top
    110 foreground application, improving performance for all foreground apps and giving
    111 apps with high intensity workloads more control over how their work is allocated
    112 across CPU cores.</p>
    113 <p>To support an exclusive core on a device:</p>
    114 <ul>
    115 <li>Enable <code>cpusets</code> and configure a <code>cpuset</code> that
    116 contains only the top foreground application.</li>
    117 <li>Ensure one core (this is the exclusive core) is reserved for threads from
    118 this <code>cpuset</code>.</li>
    119 <li>Implement the getExclusiveCores API to return the core number of the
    120 exclusive core.</li>
    121 </ul>
    122 <p>To determine which processes are scheduled on which cores, use
    123 <code>systrace</code> while running any workload and verify no userspace threads
    124 from applications other than the top foreground application are scheduled on the
    125 exclusive core.</p>
    126 <p>To view a reference implementation for the Nexus 6P, refer to
    127 <code>android//device/huawei/angler/power/power.c</code>.</p>
    128