In order to fulfill the basic functions of our service, the user hereby agrees to allow Xiaomi to collect, process and use personal information which shall include but not be limited to written threads, pictures, comments, replies in the Mi Community, and relevant data types listed in Xiaomi's Private Policy. By selecting "Agree", you agree to Xiaomi's Private Policy and Content Policy .
Agree

GeekLab

[Tips & Guides] [MIUI with Tom #23] Optimize all APP for running it faster, smoother and with less battery power!

2020-06-22 14:38:23
2735 54


Hi Dear MIUI Fan's!

Today i'll show you how to Optimize all APP for running it faster, smoother and with less battery power! I'm not Android developer but i try explain all with simple word for better understanding for normal user. If you are ready than i can start!))

Foreword
To this moment your device use ART JIT Compiler for running apps. ART JIT - is a Android Runtime Just in Time. This mean Android compile code every time for running app.
The JIT compiler complements ART's current ahead-of-time (AOT) compiler and improves runtime performance, saves storage space, and speeds application and system updates. It also improves upon the AOT compiler by avoiding system slowdown during automatic application updates or recompilation of applications during over-the-air (OTA) updates.

Although JIT and AOT use the same compiler with a similar set of optimizations, the generated code might not be identical.

But ART have profile compiler AOT (Ahead of Time) and he is not activate for app in android, but you can activate it from ADB SHELL.

Profile-guided compilation.
1.The user runs the app, which then triggers ART to load the .dex file.
  • If the .oat file (the AOT binary for the.dex file) is available, ART uses it directly. Although .oat files are generated regularly, they don't always contain compiled code (AOT binary).
  • If the .oat file does not contain compiled code, ART runs through JIT and the interpreter to execute the .dex file.
2. JIT is enabled for any application that is not compiled according to the speed compilation filter (which says "compile as much as you can from the app").
3. The JIT profile data is dumped to a file in a system directory that only the application can access.
4. The AOT compilation (dex2oat) daemon parses that  file to drive its compilation.

And now let's look at the pros and cons:

Pros:
- Run APP faster
- Use less power

Cons:
- Applications install a little longer (but not very noticeably)
- Use more storage

!!!Warning!!!
This is not recomend to use on device with 16\32 GB storage

If briefly the following commands make it possible to compile the code into an offline profile (.aot file) to run applications.
Do not forget!! The more applications installed, the more space will be taken after a new compilation.

Here is a resoult

Tutorial

Download Platform-tools and run CMD from folder Platform-tool
Enable USB Debugging and USB debugging Secure Settings in Developer options your device.

To force compilation, run the following:
adb shell cmd package compile

Common use cases for force compiling a specific package:

My-Package is apk name from Settings


Example command
adb shell cmd package compile -m speed -f com.tencent.mobileqq


If command right and all ok, you will see Success word after command

  • For one APP:
adb shell cmd package compile -m speed -f my-package

Common use cases for force compiling all packages:
  • Full:
adb shell cmd package compile -m speed -f -a

Example i compile all APP

Clearing profile data (revert all back)

To clear profile data and remove compiled code, run the following with ROOT:
su

  • For one package:
adb shell cmd package compile --reset my-package

  • For all packages:
adb shell cmd package compile --reset -a

Thanks to all for your time!
Also thanks to Admin MIUI Community!
Related thread:
[MIUI with Tom #20] How to use ADB and FASTBOOT Command directly from CMD!
[MIUI with Tom #22] How You Can Check ARB Version MIUI ROM before Downgrade!

Rate

Number of participants 9 Experience +109 Pack Reason

View Rating Log

2020-06-22 14:38:23
Favorites49 RateRate
Awesome tutorial and amazing efforts in simplifying the steps from u my friend as usual, Thanks for sharing
2020-06-22 15:17:24

Master Bunny

arawak8 | from app

#2

Thanks for sharing
2020-06-22 16:38:04

Grand Master Bunny

DaMgaSea | from Redmi Note 8 Pro

#3

2020-06-22 17:00:00

Master Bunny

Suter | from Redmi Note 7

#4

Great tutorial again thanks.
2020-06-22 17:15:25

Pro Bunny

Tom-GER | from Mi Note 10

#5

great! thanks for sharing
2020-06-22 17:29:12

Mi French Team

Mi-FE | from app

#6

thanks for sharing
2020-06-22 18:04:05

Pro Bunny

Fansh1ne | from Redmi Note 8

#7

Thanks 👍
2020-06-22 19:24:27
Useful
2020-06-22 19:36:12
Great work mate...
2020-06-22 21:15:03

Wizard Bunny

BeingBishal | from Mi 9T Pro

#10

Helpful Tutorial!
2020-06-22 22:43:18
please sign in to reply.
Sign In Sign Up

TomHenson

Super Moderador

Check-in 3 jours
Check-in 7 jours
Check-in 21 jours
Check-in 40 jours
Check-in 70 jours
Newbie Member
100 Коментарів
100 Тем
New Home
10k Mi Fans
Redmi Note 7
Cast Away
20K Mi Fans
Mi Love U & I
Bunny Winner
20K Mi Fans
Best Mi
Android Q
50K Mi Fans
Mobile Photography Lover
70K Mi Fans
Challenger
Eid ul-Fitr Mubarak
Brain Teaser
100K Mi Fans
Selfie Day
Mi 9T
Global Fans
My Country My Pride
Like
Check in
Reply
Favorites
Post
Profile Medal
MIUI 9th Birthday
Global Community
500
Redmi 7A
better together slogan
Global Community
games discuss
Mid-Autumn Festival
200K Mi Fans
400K Mi Fans
300K Mi Fans
2020
MIUI 11
close up
Halloween
Best Photo
MIUI12
10 years

Read moreGet new
Copyright©2010-2020 Xiaomi.com, All Rights Reserved
Content Policy
Quick Reply To Top Return to the list