اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release بدلاً من aosp-main لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتيح الإصدار 11 من نظام التشغيل Android أو الإصدارات الأحدث إنشاء ملفات تعريف لصورة التمهيد، وهي تتضمّن معلومات حول رمز مختلف المكوّنات على مستوى النظام، مثل خادم النظام ومسار فئة التمهيد. يستخدم Android Runtime (ART) هذه المعلومات لإجراء عمليات تحسين على مستوى النظام، وبعضها ضروري لأداء Android ويؤثر في تنفيذ جميع الرموز غير الأصلية (على مستوى النظام أو التطبيق). في بعض الحالات، يمكن أن تؤثر ملفات تعريف صورة التشغيل في أداء التنفيذ واستهلاك الذاكرة بنسب مئوية تتألف من رقمَين.
الحصول على معلومات ملف التشغيل
يتم استخلاص ملفات تعريف صور التشغيل من ملفات تعريف التطبيقات التي يتم تنفيذها أثناء
رحلات المستخدمين المهمة (CUJ). في إعدادات جهاز معيّنة، تسجّل ART (كجزء من ملفات JIT) طرق وفئات مسار فئة التمهيد التي تستخدمها التطبيقات، ثم تسجّل هذه المعلومات في ملف تعريف التطبيق (على سبيل المثال، /data/misc/profiles/cur/0/com.android.chrome/primary.prof)، حيث يتم فهرسته حسب ملف Dalvik EXecutable (DEX) لمسار فئة التمهيد (راجِع تنسيق ملف تعريف ART).
راجِع ملفات تعريف التطبيق التي تم تسجيلها أثناء رحلات المستخدمين المهمة لتحديد الجزء الأكثر استخدامًا والأكثر أهمية من مسار فئة التمهيد الذي يجب تحسينه (للاطّلاع على مثال، راجِع تنسيق ملف تعريف ART). يؤثر تضمين جميع الطرق أو الفئات سلبًا في الأداء، لذا ركِّز على مسارات الرموز الأكثر استخدامًا.
على سبيل المثال، إذا كان تطبيق واحد يستخدم طريقة من مسار فئة التمهيد، يجب ألا تكون هذه الطريقة جزءًا من ملفات تعريف التمهيد. يجب أن يضبط كل جهاز طريقة/فئة الاختيار استنادًا إلى اختيار حالة الاستخدام الشائعة ومقدار البيانات التي ينتجها الاختبار.
لتجميع معلومات مسار فئة التمهيد من جميع ملفات التطبيقات الفردية على الجهاز، شغِّل الأمر adb shell cmd package snapshot-profile android. يمكنك استخدام المعلومات المجمّعة كأساس للمعالجة واختيار الطريقة/الفئة بدون تجميع الملفات الفردية يدويًا (على الرغم من أنّه يمكنك إجراء ذلك إذا أردت).
الشكل 1. عملية الحصول على ملفات تعريف صورة التشغيل
بيانات ملف صورة التشغيل
تتضمّن ملفات تعريف صورة التشغيل الملفات والبيانات التالية.
الملف الشخصي لمسار فئة التشغيل
(frameworks/base/config/boot-image-profile.txt.
يحدّد هذا الملف الطرق التي يتم تحسينها من مسار فئة التشغيل والفئة التي يتم تضمينها في صورة .art للتشغيل.
ملف تعريف لمكوّنات خادم النظام
(frameworks/base/services/art-profile).
يحدّد هذا الملف الطرق التي يتم تحسينها/تجميعها من خادم النظام، والفئة
المضمّنة في صورة .art الخاصة بالتمهيد، وطريقة تنظيم ملفات DEX
المقابلة.
تنسيق ملف ART التعريفي
يجمع ملف ART الشخصي معلومات من كل ملفات DEX التي تم تحميلها،
بما في ذلك معلومات حول الطرق التي تستحق التحسين والفئات المستخدَمة أثناء
بدء التشغيل. عند تفعيل إنشاء ملفات تعريف صور التمهيد، يضم ART أيضًا ملفات JAR الخاصة بفئة المسار في التمهيد وخادم النظام في ملف التعريف، ويضيف تعليقًا توضيحيًا إلى كل ملف DEX يتضمّن اسم الحزمة التي تستخدمه.
على سبيل المثال، يمكنك تفريغ ملف تعريف صورة التمهيد الأولية باستخدام الأمر التالي:
تُستخدَم استراتيجية core-oj.jar في com.google.android.ext.services وcom.android.systemui. يسرد كل إدخال الحزمتَين المستخدَمتَين من
core-oj.jar.
تستخدم كلتا العمليتَين الطريقة التي تحمل فهرس DEX رقم 520، ولكن العملية systemui
فقط تستخدم الطريقة التي تحمل فهرس DEX رقم 521. وينطبق السبب نفسه على أقسام الملف الشخصي الأخرى (مثل فئات بدء التشغيل).
أثناء معالجة البيانات، يتم فلترة الطرق/الفئات استنادًا إلى الاستخدام، مع منح الأولوية للعمليات على مستوى النظام (مثل خادم النظام أو systemui) أو للطرق التي قد لا يتم استخدامها بشكل شائع ولكنها لا تزال مهمة (مثل الطرق التي يستخدمها تطبيق الكاميرا).
يضيف تنسيق الملف الشخصي بشكل داخلي تعليقات توضيحية إلى كل طريقة باستخدام علامات متعددة (مثل بدء التشغيل وما بعده ودرجة الاستخدام وواجهة التطبيق الثنائية)، وهو ما يزيد عن المعروض في التنسيق المخصص لعرض البيانات فقط. للاستفادة من جميع الإشارات، عدِّل النصوص البرمجية المتاحة.
الاقتراحات
اتّبِع الإرشادات التالية للحصول على أفضل النتائج.
انشر إعدادات إنشاء ملفات تعريف صور التمهيد على عدة أجهزة اختبار واجمع النتائج قبل إنشاء ملف تعريف صورة التمهيد النهائي. تتيح أداة profman تجميع واختيار عدة ملفات شخصية لصور التشغيل، ولكنها تعمل فقط مع الإصدار نفسه من صورة التشغيل (مسار فئة التشغيل نفسه).
منح الأولوية في الاختيار للطُرق/الفئات التي تستخدمها عمليات النظام. قد تستخدم هذه الطرق/الفئات رمزًا برمجيًا لا تستخدمه التطبيقات الأخرى غالبًا، ولكنّه يظل مهمًا لتحسين الأداء.
يختلف شكل البيانات من عملية تشغيل واحدة على جهاز واحد بشكل كبير مقارنةً بأجهزة الاختبار التي تنفّذ سيناريوهات استخدام شائعة. إذا لم يكن لديك مجموعة كبيرة من أجهزة الاختبار، استخدِم الجهاز نفسه لتنفيذ عدة رحلات مستخدم شائعة (CUJ) لزيادة الثقة في أنّ تحسينات ملف صورة التشغيل ستعمل بشكل جيد في مرحلة الإنتاج (يتم وصف هذا السيناريو أدناه).
ضبط الأجهزة
لتفعيل إعداد ملف التشغيل من خلال خصائص النظام، استخدِم إحدى الطريقتَين التاليتَين.
الخيار 1: إعداد الخصائص يدويًا (يعمل حتى إعادة التشغيل):
(اختياري) يستغرق تنسيق الملف الشخصي الجديد بعض الوقت لتنظيف الملفات الشخصية الأخرى واستبدالها. لتسريع عملية جمع الملفات الشخصية، أعِد ضبط جميع الملفات الشخصية على الجهاز.
باستخدام البيانات، عدِّل الأمر profman باستخدام علامات الحد المتاحة للاختيار.
--method-threshold
--class-threshold
--clean-class-threshold
--preloaded-class-threshold
--upgrade-startup-to-hot
--special-package
للاطّلاع على القائمة الكاملة، يُرجى الرجوع إلى صفحة المساعدة profman أو رمز المصدر.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Boot image profiles\n\nAndroid 11 or higher supports generating boot image profiles, which encapsulate\ninformation about the code of various system-level components such as system\nserver and boot classpath. Android Runtime (ART) uses this information to\nperform system-wide optimizations, some of which are critical to Android's\nperformance and impact the execution of all nonnative code (system or app\nlevel). In some cases, boot image profiles can impact execution performance and\nmemory consumption by double digit percentages.\n| **Note:** This page doesn't detail specific optimizations (such as profile guided optimizations, Zygote preloading, and `.art` images) or how profiles hook into the build system.\n\nGet boot profile information\n----------------------------\n\nBoot image profiles are derived from the profiles of apps executed during\ncritical user journeys (CUJs). In a specific device configuration, ART captures\n(as part of the JIT profiles) the boot classpath methods and classes used by\napps, then records that information in the app profile (for example,\n`/data/misc/profiles/cur/0/com.android.chrome/primary.prof`), where it's\nindexed by the boot classpath Dalvik EXecutable (DEX) file (see [ART profile\nformat](#art-profile-format)).\n| **Key Point:** Boot image profiles are built into the system image and can't be updated outside OTAs, so it's critical to select a good set of profiles before creating an image.\n\nReview the app profiles recorded during CUJs to determine which part of the boot\nclasspath is most used and most important to optimize (for an example, see [ART\nprofile format](#art-profile-format)). Including all methods or classes\nnegatively affects performance, so focus on the most commonly used code paths.\nFor example, if a method from the boot classpath is used by a single app, it\nshouldn't be part of the boot profiles. Each device should configure the\nmethod/class selection based on the CUJ selection and the amount of data\nproduced by testing.\n\nTo aggregate boot classpath information from all individual app profiles on the\ndevice, run the `adb shell cmd package snapshot-profile android` command. You\ncan use the aggregated information as the basis for processing and method/class\nselection without manually aggregating individual profiles (although you can do\nthat if desired).\n\n**Figure 1.** Process for getting boot image profiles\n\n### Boot image profile data\n\nBoot image profiles include the following files and data.\n\n- Profile for the boot classpath\n ([`frameworks/base/config/boot-image-profile.txt`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/boot/boot-image-profile.txt).\n Determines which methods from the boot classpath get optimized and which class\n is included in the boot `.art` image.\n\n- List of [preloaded\n classes](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/config/preloaded-classes).\n Determines which classes are preloaded in Zygote.\n\n- Profile for the system server components\n ([`frameworks/base/services/art-profile`](https://cs.android.com/android/platform/superproject/+/android-latest-release:frameworks/base/services/art-profile;l=1?q=art-profile&sq=)).\n Determines which methods from the system server get optimized/compiled, which\n class is included in the boot `.art` image, and how the corresponding DEX\n files are laid out.\n\n| **Note:** The system server contains multiple JAR files and each JAR gets its own profile (as opposed to the boot classpath, where all the data is in the same file). This page describes the profile for `services.jar`.\n\n### ART profile format\n\nThe ART profile captures information from each of the loaded DEX files,\nincluding information about methods worth optimizing and classes used during\nstartup. When boot image profiling is enabled, ART also includes the boot\nclasspath and system server JAR files in the profile and annotates each DEX file\nwith the name of the package that uses it.\n\nFor example, dump the raw boot image profile with the following command: \n\n adb shell profman --dump-only --profile-file=/data/misc/profman/android.prof\n\nThis produces output similar to: \n\n === Dex files ===\n === profile ===\n ProfileInfo [012]\n\n core-oj.jar:com.google.android.ext.services [index=0] [checksum=e4e3979a]\n hot methods: 520[], 611[] ...\n startup methods: ...\n classes: ...\n ...\n core-oj.jar:com.android.systemui [index=94] [checksum=e4e3979a]\n hot methods: 520[], 521[]...\n startup methods: ...\n classes: ...\n\nIn the above example:\n\n- `core-oj.jar` is used by `com.google.android.ext.services` and\n `com.android.systemui`. Each entry lists the two packages used from\n `core-oj.jar`.\n\n- Both processes use the method with DEX index 520, but only the `systemui`\n process uses the method with DEX index 521. The same rationale applies to the\n other profile sections (for example, the startup classes).\n\nDuring data processing, filter methods/classes based on usage, giving priority\nto system-level processes (for example, the system server or `systemui`) or to\nmethods that might not be commonly used but are still important (for example,\nmethods used by the camera app).\n\nThe profile format internally annotates each method with multiple flags\n(startup, post-startup, hotness, abi), which is more than is displayed in the\ndump-only format. To make use of all the signals, modify the available scripts.\n\n### Recommendations\n\nUse the following guidelines for best results.\n\n- Deploy the configuration for generating boot image profiles to several test\n devices and aggregate the results before generating the final boot image\n profile. The `profman` tool supports aggregating and selecting multiple boot\n image profiles, but it works only with the same version of the boot image\n (same boot classpath).\n\n- Give selection priority to the methods/classes that are used by system\n processes. These methods/classes might use code that isn't often used by other\n apps but that's still critical to optimize.\n\n- The data shape from a single device run looks very different compared to test\n devices that execute real-world CUJs. If you don't have a large fleet of test\n devices, use the same device to run several CUJs to increase the confidence\n that the boot image profile optimizations will work well in production (this\n scenario is described below).\n\nConfigure devices\n-----------------\n\nTo enable boot profile configuration through system properties, use one of the\nfollowing methods.\n\n- **Option 1:** Manually set up props (works up to reboot):\n\n adb root\n adb shell stop\n adb shell setprop dalvik.vm.profilebootclasspath true\n adb shell setprop dalvik.vm.profilesystemserver true\n adb shell start\n\n- **Option 2:** Use a `local.prop` (permanent effect until the file is deleted).\n To do so:\n\n 1. Create a `local.prop` file with the content:\n\n dalvik.vm.profilebootclasspath=true\n dalvik.vm.profilesystemserver=true\n\n 2. Run the following commands:\n\n adb push local.prop /data/\n adb shell chmod 0750 /data/local.prop\n adb reboot\n\n- **Option 3:** Use device configuration to set the following server-side\n properties:\n\n adb shell device_config put runtime_native_boot profilebootclasspath true\n adb shell device_config put runtime_native_boot profilesystemserver true\n\n| **Note:** The `art/tools/boot-image-profile-configure-device.sh` script includes the above steps.\n\nGenerate boot image profiles\n----------------------------\n\nUse the following instructions to generate a basic boot image profile using\ntesting on a single device.\n\n1. Set up the device.\n\n 1. Configure the device as described in [Configuring\n devices](#configuring-devices).\n\n 2. (Optional) It takes time for the new profile format to clean and replace the\n other profiles. To speed up profile collection, reset all profiles on the\n device.\n\n adb shell stop\n adb shell find \"/data/misc/profiles -name *.prof -exec truncate -s 0 {} \\;\"\n adb shell start\n\n 3. Run the CUJs on the device.\n\n2. Capture the profile using the following command:\n\n adb shell cmd package snapshot-profile android\n\n3. Extract the profile using the following command:\n\n adb pull /data/misc/profman/android.prof\n\n4. Navigate to the boot classpath JAR files using the following commands:\n\n m dist\n ls $ANDROID_PRODUCT_OUT/boot.zip\n\n5. Generate the boot image profile using the following `profman` command.\n\n profman --generate-boot-image-profile --profile-file=android.prof --out-profile-path=... --out-preloaded-classes-path=...\n\n6. Using data, tweak the `profman` command using the available selection\n threshold flags.\n\n - `--method-threshold`\n - `--class-threshold`\n - `--clean-class-threshold`\n - `--preloaded-class-threshold`\n - `--upgrade-startup-to-hot`\n - `--special-package`\n\n To view the full list, refer to the `profman` help page or source code.\n\n| **Note:** The `art/tools/boot-image-profile-generate.sh` script includes these steps."]]