ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
การเพิ่มประสิทธิภาพตามความคิดเห็นอัตโนมัติ (12 ขึ้นไป)
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ระบบบิลด์ Android ที่เปิดตัวใน Android 12 รองรับการเพิ่มประสิทธิภาพโมดูล Android เนทีฟที่มีกฎการสร้างบิลด์ของพิมพ์เขียวโดยใช้การเพิ่มประสิทธิภาพโดยอัตโนมัติตามความคิดเห็นที่ได้รับ (AutoFDO) AutoFDO เป็นเทคนิคการเพิ่มประสิทธิภาพที่อิงตามการสุ่มตัวอย่าง AutoFDO จะบันทึกลักษณะการทำงานรันไทม์ของไบนารีของระบบ ซึ่งช่วยให้คอมไพเลอร์เพิ่มประสิทธิภาพได้ดียิ่งขึ้นและลดขนาดไบนารีได้ด้วย Android รองรับการเก็บรวบรวมโปรไฟล์จากอุปกรณ์ X86, X86_64, ARM และ ARM64 แม้ว่าโปรไฟล์จะใช้ได้กับสถาปัตยกรรมต่างๆ
AutoFDO เป็นเครื่องมือที่สืบทอดมาจากการเพิ่มประสิทธิภาพตามโปรไฟล์ที่อิงตามเครื่องมือวัด (PGO)
AutoFDO มีข้อดีเพิ่มเติมต่อไปนี้เมื่อเทียบกับโปรไฟล์ที่อิงตามเครื่องมือวัดอื่นๆ
การรวบรวมข้อมูลที่รบกวนผู้ใช้น้อยที่สุด: รวบรวมโปรไฟล์ AutoFDO จากอุปกรณ์การพัฒนาหรืออุปกรณ์ของผู้ใช้ได้โดยไม่ต้องแก้ไขกฎการสร้าง
การนําเสนอการใช้งานในชีวิตจริง: AutoFDO แสดงพฤติกรรมการใช้งานในชีวิตจริงโดยสมมติว่ามีการรวบรวมโปรไฟล์จากอุปกรณ์ของผู้ใช้ ส่วน PGO ที่ใช้เครื่องมือวัดจะแสดงถึงภาระงานการรวบรวมข้อมูลสังเคราะห์เท่านั้น โดยทั่วไปแล้ว การสร้างปริมาณงานของคอลเล็กชันที่ตรงกับการใช้งานจริงอย่างสมบูรณ์นั้นไม่ใช่เรื่องง่าย
AOSP มาพร้อมกับโปรไฟล์ AutoFDO สําหรับโปรเจ็กต์ที่เน้นประสิทธิภาพส่วนใหญ่ โดยรวบรวมโปรไฟล์จากอุปกรณ์โทรศัพท์และแท็บเล็ต และแสดงถึงรูปแบบการใช้งานทั่วไป โปรไฟล์จะอยู่ในส่วน
toolchain/pgo-profiles/sampling
AFDO จะเปิดใช้โดยค่าเริ่มต้นใน AOSP
เปิดใช้ AutoFDO สําหรับกฎการสร้างบิลด์เพลต
หากต้องการเปิดใช้ AutoFDO สำหรับกฎการสร้างบิลด์ ให้ใส่ afdo: true
ต่อท้ายกฎไลบรารีหรือไบนารีที่แชร์
รวบรวมโปรไฟล์
โปรไฟล์ที่รวมไว้ล่วงหน้าซึ่งมาพร้อมกับ AOSP ไม่รองรับสถานการณ์ต่อไปนี้
- การรวมโปรเจ็กต์ AutoFDO เพิ่มเติม
- การมีโค้ดที่แก้ไขในเครื่อง
- รูปแบบการใช้งานที่ไม่ซ้ำซึ่งเชื่อมโยงกับระบบของคุณ
หากมีสถานการณ์ใดสถานการณ์หนึ่งเหล่านี้ คุณต้องรวบรวมโปรไฟล์จากอุปกรณ์การพัฒนาหรืออุปกรณ์ของผู้ใช้โดยตรง
โปรดดูวิธีการโดยละเอียดเกี่ยวกับวิธีเตรียมอุปกรณ์ ARM เพื่อรวบรวมโปรไฟล์ AutoFDO ที่หัวข้อรวบรวมข้อมูล ETM สําหรับ AutoFDO
ดูวิธีการโดยละเอียดเกี่ยวกับวิธีเตรียมอุปกรณ์ X86 เพื่อรวบรวมโปรไฟล์ AutoFDO ได้ที่รวบรวมข้อมูล LBR สําหรับ AutoFDO
ดูข้อมูลเกี่ยวกับวิธีเปิดใช้การเก็บรวบรวม ประมวลผล และอัปโหลดโปรไฟล์ในเบื้องหลังโดยอัตโนมัติได้ที่ Profcollect
วิเคราะห์โปรไฟล์ AutoFDO
Android ใช้โปรไฟล์ LLVM AutoFDO มาตรฐาน โปรไฟล์ AFDO อ่านได้โดยใช้เครื่องมือ llvm-profdata
ของ LLVM สคริปต์ afdo_summary.sh
(toolchain/pgo-profiles/scripts/afdo_summary.sh
) จะสร้างฟังก์ชันที่เรียกใช้บ่อยที่สุดโดยอัตโนมัติตามโปรไฟล์ AutoFDO
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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 UTC"],[],[],null,["# Automatic Feedback-Directed Optimization (12 or higher)\n\nIntroduced in Android 12, the Android build system supports optimizing native\nAndroid modules that have blueprint build rules using *Automatic\nFeedback-Directed Optimization (AutoFDO)*. AutoFDO is a sampling-based\noptimization technique. AutoFDO captures the runtime behavior of system\nbinaries, enabling compilers to make better performance optimizations while also\nreducing binary size. Android supports collecting profiles from X86, X86_64,\nARM, and ARM64 devices, although the profiles can be used across architectures.\n\nAutoFDO is the successor for instrumentation-based Profile-Guided Optimization\n(PGO).\n\nCompared to other instrumentation based profiles, AutoFDO has these additional\nbenefits:\n\n- Unobtrusive data collection: AutoFDO profiles can be collected from\n development or user devices without any modification to build rules.\n\n- Real-world usage representation: AutoFDO represents real-world usage behavior\n assuming profiles are collected from user devices, while instrumentation PGO\n is representative only of the synthetic collection workload. It isn't\n generally straightforward to create a collection workload that perfectly\n matches real world usage.\n\nAOSP ships with AutoFDO profiles for most performance-critical projects. The\nprofiles were collected from phone and tablet devices, and are representative of\ntheir general usage patterns. The profiles are located under\n`toolchain/pgo-profiles/sampling`. AFDO is enabled by default on AOSP.\n\nEnable AutoFDO for a blueprint build rule\n-----------------------------------------\n\nTo enable AutoFDO for blueprint build rules, append `afdo: true` to the shared\nlibrary or binary rule.\n\nCollect profiles\n----------------\n\nThe prebundled profile provided with AOSP doesn't support these specific\nscenarios:\n\n- The inclusion of additional AutoFDO projects\n- The presence of locally modified code\n- Unique usage patterns associated with your system\n\nIf you have one of these scenarios, you must gather profiles directly from\ndevelopment or user devices.\n\nFor detailed instruction on how to prepare ARM devices for\ncollecting AutoFDO profiles, refer to\n[Collect ETM data for\nAutoFDO](https://android.googlesource.com/platform/system/extras/+/refs/heads/android16-release/simpleperf/doc/collect_etm_data_for_autofdo.md).\n\nFor detailed instruction on how to prepare X86 devices for\ncollecting AutoFDO profiles, refer to [Collect LBR data for\nAutoFDO](https://android.googlesource.com/platform/system/extras/+/refs/heads/android16-release/simpleperf/doc/collect_lbr_data_for_autofdo.md).\n\nFor information on how to enable automatic background profile collection,\nprocessing, and uploading, see\n[Profcollect](https://android.googlesource.com/platform/system/extras/+/refs/heads/android16-release/profcollectd/README.md).\n\nAnalyze AutoFDO profiles\n------------------------\n\nAndroid uses standard LLVM AutoFDO profiles. The AFDO profiles can be read\nusing the LLVM's `llvm-profdata` tool. The `afdo_summary.sh` script\n([`toolchain/pgo-profiles/scripts/afdo_summary.sh`](https://cs.android.com/android/platform/superproject/+/android-latest-release:toolchain/pgo-profiles/scripts/afdo_summary.sh))\nautomatically generates the most frequently executed functions according to the\nAutoFDO profile."]]