diff options
Diffstat (limited to 'en/devices/tech/dalvik/jit-compiler.html')
-rw-r--r-- | en/devices/tech/dalvik/jit-compiler.html | 224 |
1 files changed, 5 insertions, 219 deletions
diff --git a/en/devices/tech/dalvik/jit-compiler.html b/en/devices/tech/dalvik/jit-compiler.html index 9090349c..74ac6de0 100644 --- a/en/devices/tech/dalvik/jit-compiler.html +++ b/en/devices/tech/dalvik/jit-compiler.html @@ -46,12 +46,6 @@ do OSR compilation (on stack replacement) which will again generate a bit different code. </p> -<p> -See <a -href="https://developer.android.com/preview/api-overview.html#jit_aot">Profile-guided -JIT/AOT Compilation</a> on developer.android.com for a more thorough overview. -</p> - <h2 id="architectural-overview">Architectural Overview</h2> <img src="/devices/tech/dalvik/images/jit-arch.png" alt="JIT architecture" width="633" id="JIT-architecture" /> @@ -132,82 +126,7 @@ memory than small apps. In general, big apps stabilize around 4 MB.</li></ul> </li> </ul> -<h2 id="system-properties">System Properties</h2> - -<p> -These system properties control JIT behavior: -</p><ul> -<li><code>dalvik.vm.usejit <true|false></code> - Whether or not the JIT is -enabled. -<li><code>dalvik.vm.jitinitialsize</code> (default 64K) - The initial capacity -of the code cache. The code cache will regularly GC and increase if needed. It -is possible to view the size of the code cache for your app with:<br> -<code> $ adb shell dumpsys meminfo -d <pid></code> -<li><code>dalvik.vm.jitmaxsize</code> (default 64M) - The maximum capacity of -the code cache. -<li><code>dalvik.vm.jitthreshold <integer></code> (default 10000) - This -is the threshold that the "hotness" counter of a method needs to pass in order -for the method to be JIT compiled. The "hotness" counter is a metric internal -to the runtime. It includes the number of calls, backward branches & other -factors. -<li><code>dalvik.vm.usejitprofiles <true|false></code> - Whether or not -JIT profiles are enabled; this may be used even if usejit is false. -<li><code>dalvik.vm.jitprithreadweight <integer></code> (default to -<code>dalvik.vm.jitthreshold</code> / 20) - The weight of the JIT "samples" -(see jitthreshold) for the application UI thread. Use to speed up compilation -of methods that directly affect users experience when interacting with the -app. -<li><code>dalvik.vm.jittransitionweight <integer></code> -(<code>dalvik.vm.jitthreshold</code> / 10) - The weight of the method -invocation that transitions between compile code and interpreter. This helps -make sure the methods involved are compiled to minimize transitions (which are -expensive). -</li> -</ul> - -<h2 id="tuning">Tuning</h2> - -<p> -Device implementers may precompile (some of) the system apps if they want so. -Initial JIT performance vs pre-compiled depends on the app, but in general -they are quite close. It might be worth noting that precompiled apps will not -be profiled and as such will take more space and may miss on other -optimizations. -</p> - -<p> -In Android 7.0, there's a generic way to specify the level of -compilation/verification based on the different use cases. For example, the -default option for install time is to do only verification (and postpone -compilation to a later stage). The compilation levels can be configured via -system properties with the defaults being: -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.install=interpret-only -pm.dexopt.bg-dexopt=speed-profile -pm.dexopt.ab-ota=speed-profile -pm.dexopt.nsys-library=speed -pm.dexopt.shared-apk=speed -pm.dexopt.forced-dexopt=speed -pm.dexopt.core-app=speed -pm.dexopt.first-boot=interpret-only -pm.dexopt.boot=verify-profile -</pre> - -<p> -See the <a href="#recommendation">Recommendation</a> section for use. -</p> - -<p> -Note the reference to A/B over-the-air (OTA) updates here. -</p> - -<p> -Check <code>$ adb shell cmd package compile</code> for usage. Note all commands -in this document are preceded by a dollar ($) sign that should be excluded when -copying and pasting. A few common use cases: -</p> +<h2 id="tuning">Useful tips</h2> <h3 id="turn-on-jit-logging">Turn on JIT logging</h3> @@ -230,6 +149,10 @@ copying and pasting. A few common use cases: <h3 id="force-compilation-of-a-specific-package">Force compilation of a specific package</h3> +<p> +Check <code>$ adb shell cmd package compile</code> for usage. A few common use cases: +</p> + <ul> <li>Profile-based: <pre class="devsite-terminal devsite-click-to-copy"> @@ -275,142 +198,5 @@ adb shell cmd package compile --reset -a </li> </ul> -<h2 id="recommendation">Recommendation</h2> - -<h3 id="runtime_compilation_level">Level of compilation/verification</h3> - -<p> -Note that it is strongly recommended to use the default following -<code>pm.dexopt</code> settings and it is the only path we have tested and will -support. -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.install=interpret-only -pm.dexopt.bg-dexopt=speed-profile -pm.dexopt.boot=verify-profile (or interpret-only) -</pre> - -<p> -Here’s a detailed explanation about the <code>pm.dexopt</code> options, and the -reasoning for our recommendations: -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.install -</pre> - -<p> -This is the compilation filter used when installing application through the -Play Store. For faster installs we recommend <code>interpret-only</code>. -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.bg-dexopt -</pre> - -<p> -This is the compilation filter used when the device is idle and charging and -fully charged. We recommend using <code>speed-profile</code> to take advantage -of profile guided compilation and save on storage. -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.ab-ota -</pre> - -<p> -This is the compilation filter used when doing an A/B over-the-air (OTA) -update. If the device supports A/B OTA, we recommend using -<code>speed-profile</code> to take advantage of profile guided compilation and -save on storage. -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.nsys-library -pm.dexopt.shared-apk -pm.dexopt.core-app -</pre> - -<p> -You can use these different options to control how to compile essentially -applications used by other applications. For such applications, we recommend -the <code>speed</code> filter, as the platform does not support efficient -profiling of them. -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.first-boot -</pre> - -<p> -The compilation filter for the first time the device ever boots. The filter -used here will only affect the boot time after factory. We recommend the filter -<code>interpret-only</code> for it, to avoid long times before a user gets to -use the phone for the very first time. Note that if all applications in /system -are already speed compiled, <code>pm.dexopt.first-boot</code> has no effect. -</p> - -<pre class="devsite-click-to-copy"> -pm.dexopt.boot -</pre> - -<p> -The compilation filter used after an over-the-air update. We -<strong>strongly</strong> recommend <code>verify-profile</code> for this -option, to avoid very long updates. -</p> - -<h3 id="system_image_compilation_level">System image</h3> - -<p> -This section gives recommendations on how to minimize the system image size -while retaining the highest possible level of performance. -Note these complement the above guidelines on the -<a href="#runtime_compilation_level">level of compilation/verification</a>. -</p> - -<p> -System image size can be reduced by opting for a lower level of compilation for -prebuilts. To achieve the best compromise between app performance and image size, -we strongly recommend compiling prebuilts with the <code>interpret-only</code> -filter. To do this, edit the following files to include these entries. -</p> - -<p>Add the following entry to <code>BoardConfig.mk</code>:</p> - -<pre class="devsite-click-to-copy"> -WITH_DEXPREOPT := true -</pre> - -<p>Add the following entry to <code>device.mk</code>:</p> - -<pre class="devsite-click-to-copy"> -PRODUCT_DEX_PREOPT_DEFAULT_FLAGS := --compiler-filter=interpret-only -</pre> - -<p> -Using the <code>interpret-only</code> filter will reduce the optimized code -size for prebuilts by roughly half (depending on the application) when -compared with the <code>speed</code> filter. It also allows the runtime to -profile the prebuilts and perform profile-guided compilation to further -save on data partition storage. -</p> - -<p> -We advise against using a lower compilation/verification level -(e.g. <code>verify-none</code>) or disabling the optimization for prebuilts -as an effort to further save space on the system image. That will lead to slower -application startup and increased memory consumption. -</p> - -<h2 id="validation">Validation</h2> - -<p> -To ensure their version of the feature works as intended, device implementers -should run the ART test in <code>android/art/test</code>. Also, see the CTS -test <code>hostsidetests/compilation</code> for userdedug builds. -</p> - </body> </html> |