• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1page.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
27applications run consistently and smoothly on a wide range of hardware. In
28Android 7.0, OEMs can implement support for sustained performance hints that
29enable apps to maintain a consistent device performance and specify an exclusive
30core 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
34processing), performance can vary dramatically as device temperature limits are
35reached and system on chip (SoC) engines are throttled. App developers creating
36high-performance, long-running apps are limited because the capabilities of the
37underlying 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
40performance, enabling OEMs to provide hints on device performance capabilities
41for long-running applications. App developers can use these hints to tune
42applications for a predictable, consistent level of device performance over long
43periods of time.</p>
44
45<h3 id=architecture>Architecture</h3>
46<p>An Android application can request the platform to enter a sustained
47performance mode where the Android device can keep a consistent level of
48performance 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
52architecture</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
58CPU/GPU frequencies <strong>or</strong> perform other optimizations to prevent
59thermal throttling.</li>
60<li>Implement the new hint <code>POWER_HINT_SUSTAINED_PERFORMANCE</code> in
61power 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
68maximum frequencies of the CPU and GPU at the highest sustainable levels. Keep
69in mind that lowering the MAX bar in CPU/GPU frequency will lower the frame
70rate, but this lower rate is preferred in this mode due to its sustainability.
71For example, a device using normal max clocks might be able to render at 60
72FPS for a few minutes, but after the device heats up,  it may throttle to 30 FPS
73by the end of 30 minutes. When using sustained mode, the device can, for
74example, render consistently at 45 FPS for the entire 30 minutes. The goal is a
75frame rate when using the mode that is as high (or higher) than the frame rate
76when not using the mode, and consistent over time so that developers don't have
77to chase a moving target.</p>
78<p>We strongly recommend implementing sustained mode such that the device
79achieves the highest possible sustained performance—not just the minimum values
80required to pass the test (e.g. choose the highest possible MAX frequency caps
81that 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
84to 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
88sustained performance API. The test runs a workload for approximately 30 minutes
89and 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
95rate 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
98GPU-intensive workloads to ensure the device does not thermally throttle after
9930 minutes of use. In internal testing, we used sample workloads including
100games 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
105thread can be the difference between making frame deadlines or not. For apps
106that have strict latency and frame rate requirements (such as audio or virtual
107reality apps), having an exclusive CPU core can guarantee an acceptable level of
108performance.</p>
109<p>Devices running Android 7.0 can now reserve one core explicitly for the top
110foreground application, improving performance for all foreground apps and giving
111apps with high intensity workloads more control over how their work is allocated
112across 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
116contains only the top foreground application.</li>
117<li>Ensure one core (this is the exclusive core) is reserved for threads from
118this <code>cpuset</code>.</li>
119<li>Implement the getExclusiveCores API to return the core number of the
120exclusive 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
124from applications other than the top foreground application are scheduled on the
125exclusive 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