বুট ইমেজ প্রোফাইল

অ্যান্ড্রয়েড ১১ বা তার উচ্চতর সংস্করণ বুট ইমেজ প্রোফাইল তৈরি করা সমর্থন করে, যা সিস্টেম সার্ভার এবং বুট ক্লাসপাথের মতো বিভিন্ন সিস্টেম-স্তরের উপাদানের কোড সম্পর্কিত তথ্য ধারণ করে। অ্যান্ড্রয়েড রানটাইম (ART) এই তথ্য ব্যবহার করে সিস্টেম-ব্যাপী অপ্টিমাইজেশন সম্পাদন করে, যার মধ্যে কিছু অ্যান্ড্রয়েডের পারফরম্যান্সের জন্য অত্যন্ত গুরুত্বপূর্ণ এবং সমস্ত নননেটিভ কোডের (সিস্টেম বা অ্যাপ স্তরের) নির্বাহকে প্রভাবিত করে। কিছু ক্ষেত্রে, বুট ইমেজ প্রোফাইল নির্বাহের পারফরম্যান্স এবং মেমরি ব্যবহারকে দুই অঙ্কের শতাংশে প্রভাবিত করতে পারে।

Get boot profile information

ক্রিটিক্যাল ইউজার জার্নি (CUJ) চলাকালীন এক্সিকিউট হওয়া অ্যাপগুলোর প্রোফাইল থেকে বুট ইমেজ প্রোফাইল তৈরি করা হয়। একটি নির্দিষ্ট ডিভাইস কনফিগারেশনে, ART (JIT প্রোফাইলের অংশ হিসেবে) অ্যাপগুলো দ্বারা ব্যবহৃত বুট ক্লাসপাথ মেথড এবং ক্লাসগুলো ক্যাপচার করে, এবং তারপর সেই তথ্য অ্যাপ প্রোফাইলে রেকর্ড করে (উদাহরণস্বরূপ, /data/misc/profiles/cur/0/com.android.chrome/primary.prof ), যেখানে এটি বুট ক্লাসপাথ ডালভিক এক্সিকিউটেবল (DEX) ফাইল দ্বারা ইনডেক্স করা হয় ( ART প্রোফাইল ফরম্যাট দেখুন)।

CUJ চলাকালীন রেকর্ড করা অ্যাপ প্রোফাইলগুলো পর্যালোচনা করে নির্ধারণ করুন যে বুট ক্লাসপাথের কোন অংশটি সবচেয়ে বেশি ব্যবহৃত হয় এবং অপ্টিমাইজ করার জন্য সবচেয়ে গুরুত্বপূর্ণ (উদাহরণস্বরূপ, ART প্রোফাইল ফরম্যাট দেখুন)। সমস্ত মেথড বা ক্লাস অন্তর্ভুক্ত করা পারফরম্যান্সের উপর নেতিবাচক প্রভাব ফেলে, তাই সবচেয়ে বেশি ব্যবহৃত কোড পাথগুলোর উপর মনোযোগ দিন। উদাহরণস্বরূপ, যদি বুট ক্লাসপাথের কোনো মেথড একটিমাত্র অ্যাপ দ্বারা ব্যবহৃত হয়, তবে সেটি বুট প্রোফাইলের অংশ হওয়া উচিত নয়। প্রতিটি ডিভাইসের উচিত CUJ নির্বাচন এবং টেস্টিং থেকে প্রাপ্ত ডেটার পরিমাণের উপর ভিত্তি করে মেথড/ক্লাস নির্বাচন কনফিগার করা।

To aggregate boot classpath information from all individual app profiles on the device, run the adb shell cmd package snapshot-profile android command. You can use the aggregated information as the basis for processing and method/class selection without manually aggregating individual profiles (although you can do that if desired).

Boot image profile

চিত্র ১. বুট ইমেজ প্রোফাইল পাওয়ার প্রক্রিয়া

Boot image profile data

বুট ইমেজ প্রোফাইলে নিম্নলিখিত ফাইল ও ডেটা অন্তর্ভুক্ত থাকে।

ART profile format

The ART profile captures information from each of the loaded DEX files, including information about methods worth optimizing and classes used during startup. When boot image profiling is enabled, ART also includes the boot classpath and system server JAR files in the profile and annotates each DEX file with the name of the package that uses it.

উদাহরণস্বরূপ, নিম্নলিখিত কমান্ডের সাহায্যে র বুট ইমেজ প্রোফাইলটি ডাম্প করুন:

adb shell profman --dump-only --profile-file=/data/misc/profman/android.prof

This produces output similar to:

=== Dex files  ===
=== profile ===
ProfileInfo [012]

core-oj.jar:com.google.android.ext.services [index=0] [checksum=e4e3979a]
        hot methods: 520[], 611[] …
        startup methods: …
        classes: …
...
core-oj.jar:com.android.systemui [index=94] [checksum=e4e3979a]
        hot methods: 520[], 521[]…
        startup methods: …
        classes: …

In the above example:

  • core-oj.jar com.google.android.ext.services এবং com.android.systemui দ্বারা ব্যবহৃত হয়। প্রতিটি এন্ট্রিতে core-oj.jar থেকে ব্যবহৃত দুটি প্যাকেজের তালিকা দেওয়া থাকে।

  • Both processes use the method with DEX index 520, but only the systemui process uses the method with DEX index 521. The same rationale applies to the other profile sections (for example, the startup classes).

During data processing, filter methods/classes based on usage, giving priority to system-level processes (for example, the system server or systemui ) or to methods that might not be commonly used but are still important (for example, methods used by the camera app).

The profile format internally annotates each method with multiple flags (startup, post-startup, hotness, abi), which is more than is displayed in the dump-only format. To make use of all the signals, modify the available scripts.

সুপারিশসমূহ

Use the following guidelines for best results.

  • Deploy the configuration for generating boot image profiles to several test devices and aggregate the results before generating the final boot image profile. The profman tool supports aggregating and selecting multiple boot image profiles, but it works only with the same version of the boot image (same boot classpath).

  • Give selection priority to the methods/classes that are used by system processes. These methods/classes might use code that isn't often used by other apps but that's still critical to optimize.

  • The data shape from a single device run looks very different compared to test devices that execute real-world CUJs. If you don't have a large fleet of test devices, use the same device to run several CUJs to increase the confidence that the boot image profile optimizations will work well in production (this scenario is described below).

Configure devices

সিস্টেম প্রোপার্টিজের মাধ্যমে বুট প্রোফাইল কনফিগারেশন চালু করতে, নিচের পদ্ধতিগুলোর মধ্যে যেকোনো একটি ব্যবহার করুন।

  • বিকল্প ১: ম্যানুয়ালি প্রপস সেট আপ করুন (রিবুট পর্যন্ত কাজ করে):

    adb root
    adb shell stop
    adb shell setprop dalvik.vm.profilebootclasspath true
    adb shell setprop dalvik.vm.profilesystemserver true
    adb shell start
  • বিকল্প ২: একটি local.prop ব্যবহার করুন (ফাইলটি মুছে না ফেলা পর্যন্ত এটি স্থায়ী থাকবে)। এটি করতে:

    1. Create a local.prop file with the content:

      dalvik.vm.profilebootclasspath=true
      dalvik.vm.profilesystemserver=true
      
    2. Run the following commands:

      adb push local.prop /data/
      adb shell chmod 0750 /data/local.prop
      adb reboot
  • বিকল্প ৩: ডিভাইস কনফিগারেশন ব্যবহার করে নিম্নলিখিত সার্ভার-সাইড প্রোপার্টিগুলো সেট করুন:

    adb shell device_config put runtime_native_boot profilebootclasspath true
    adb shell device_config put runtime_native_boot profilesystemserver true
    

Generate boot image profiles

একটি ডিভাইসে পরীক্ষা-নিরীক্ষার মাধ্যমে একটি প্রাথমিক বুট ইমেজ প্রোফাইল তৈরি করতে নিম্নলিখিত নির্দেশাবলী ব্যবহার করুন।

  1. Set up the device.

    1. ডিভাইস কনফিগার করা অংশে বর্ণিত পদ্ধতি অনুযায়ী ডিভাইসটি কনফিগার করুন।

    2. (ঐচ্ছিক) নতুন প্রোফাইল ফরম্যাট করতে এবং অন্যান্য প্রোফাইলগুলো মুছে ফেলতে সময় লাগে। প্রোফাইল সংগ্রহের প্রক্রিয়াটি দ্রুত করতে, ডিভাইসের সমস্ত প্রোফাইল রিসেট করুন।

      adb shell stop
      adb shell find "/data/misc/profiles -name *.prof -exec truncate -s 0 {} \;"
      adb shell start
    3. Run the CUJs on the device.

  2. Capture the profile using the following command:

    adb shell cmd package snapshot-profile android
  3. Extract the profile using the following command:

    adb pull /data/misc/profman/android.prof
  4. নিম্নলিখিত কমান্ডগুলি ব্যবহার করে বুট ক্লাসপাথ JAR ফাইলগুলিতে যান:

    m dist
    ls $ANDROID_PRODUCT_OUT/boot.zip
  5. নিম্নলিখিত profman কমান্ডটি ব্যবহার করে বুট ইমেজ প্রোফাইলটি তৈরি করুন।

    profman --generate-boot-image-profile --profile-file=android.prof --out-profile-path=... --out-preloaded-classes-path=...
  6. ডেটা ব্যবহার করে, উপলব্ধ সিলেকশন থ্রেশহোল্ড ফ্ল্যাগগুলোর সাহায্যে profman কমান্ডটি পরিবর্তন করুন।

    • --method-threshold
    • --class-threshold
    • --clean-class-threshold
    • --preloaded-class-threshold
    • --upgrade-startup-to-hot
    • --special-package

    সম্পূর্ণ তালিকাটি দেখতে, profman হেল্প পেজ অথবা সোর্স কোড দেখুন।