2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
자동 피드백 기반 최적화(12 또는 이후 버전)
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android 12에서 도입된 Android 빌드 시스템은 자동 피드백 기반 최적화(AutoFDO)를 사용하여 청사진 빌드 규칙이 있는 네이티브 Android 모듈의 최적화를 지원합니다. 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 프로젝트 포함
- 로컬에서 수정한 코드가 있음
- 시스템과 관련된 고유한 사용 패턴
이러한 시나리오 중 하나가 있다면 개발 기기나 사용자 기기에서 직접 프로필을 수집해야 합니다.
AutoFDO 프로필 수집을 위해 ARM 기기를 준비하는 방법에 관한 자세한 내용은 AutoFDO용 ETM 데이터 수집을 참고하세요.
AutoFDO 프로필 수집을 위해 X86 기기를 준비하는 방법에 관한 자세한 내용은 AutoFDO용 LBR 데이터 수집을 참고하세요.
자동 백그라운드 프로필 수집과 처리, 업로드를 사용 설정하는 방법에 관한 자세한 내용은 Profcollect를 참고하세요.
AutoFDO 프로필 분석
Android에서는 표준 LLVM AutoFDO 프로필을 사용합니다. AFDO 프로필은 LLVM의 llvm-profdata
도구를 사용하여 읽을 수 있습니다. afdo_summary.sh
스크립트(toolchain/pgo-profiles/scripts/afdo_summary.sh
)는 AutoFDO 프로필에 따라 가장 자주 실행된 기능을 자동 생성합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 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."]]