Commit graph

27 commits

Author SHA1 Message Date
Colin Cross
3513fb17cd Remove fdoProfileMutator
Add the dependency on the fdo_profile module in afdoTransitionMutator
and read the provider in GenerateAndroidBuildActions.

This relands Ied8fd7b52d5694a3691652318e87b8fe14dda126 with a fix
to use the correct LTO ldflag when an afdo variant doesn't have a
profile.

Bug: 319288033
Bug: 324141705
Test: afdo_test.go
Change-Id: I024ca316cfb565b5fb0251793f05a54ce16cc1cb
2024-02-09 13:49:02 -08:00
Colin Cross
d38feb0d4a Convert AFDO mutators to TransitionMutator
Convert afdoDepsMutator and afdoMutator to a TransitionMutator as a
step towards variants-on-demand.

This relands Ib05845455ccf43a07b3915a0d7b0a95896062f13 with a fix
to maintain the current behavior of not using AFDO variants for
dependencies of the linker static binary.

Bug: 319288033
Bug: 324141705
Test: afdo_test.go
Change-Id: I76e30021173fc5b7e9e1fa826039776eb3dc7b6e
2024-02-07 15:51:40 -08:00
Colin Cross
15fa814560 Disable more of AFDO for host modules
afdo.addDep would never add a depencency on a profile for a host
module, but afdoDepsMutator would still propagate AfdoRDeps to
dependencies, afdoMutator would still create afdo variants, and
afdo.flags would still add the -funique-internal-linkage-names
flag.  Exit early from all of these functions, since the afdo
variations will never be useful.

Test: afdo_test.go
Change-Id: I255fcbb86c99871916e571fbc74075d918b24745
2024-02-07 15:49:47 -08:00
Ke-Yu Lu
0be9d6034e Revert "Convert AFDO mutators to TransitionMutator"
Revert submission 2925209

Reason for revert: b/323975183

Reverted changes: /q/submissionid:2925209

Change-Id: Ie907d23081817d601a1a2083347b5f683829a36c
2024-02-06 02:15:03 +00:00
Ke-Yu Lu
351d36490d Revert "Remove fdoProfileMutator"
Revert submission 2925209

Reason for revert: b/323975183

Reverted changes: /q/submissionid:2925209

Change-Id: I33b2e71ba7b36e12e5c491e0ad14a7f7df3edd78
2024-02-06 02:15:03 +00:00
Colin Cross
943aa5c862 Remove fdoProfileMutator
Add the dependency on the fdo_profile module in afdoTransitionMutator
and read the provider in GenerateAndroidBuildActions.

Bug: 319288033
Test: afdo_test.go
Change-Id: Ied8fd7b52d5694a3691652318e87b8fe14dda126
2024-01-26 11:09:25 -08:00
Colin Cross
a6b407fbf5 Convert AFDO mutators to TransitionMutator
Convert afdoDepsMutator and afdoMutator to a TransitionMutator as a
step towards variants-on-demand.

Bug: 319288033
Test: afdo_test.go
Change-Id: Ib05845455ccf43a07b3915a0d7b0a95896062f13
2024-01-26 11:08:32 -08:00
Colin Cross
313aa5475f Convert OtherModuleProvider to generic providers API
Convert all of the callers of OtherModuleProvider/OtherModuleHasProvider
to use the type-safe android.OtherModuleProvider API.

Bug: 316410648
Test: builds
Change-Id: Id77f514d68761a262d9ea830a601dbed804bbbe5
2023-12-14 16:12:22 -08:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Yi Kong
9723e338ee Do not perform AFDO or optimizing LTO for eng builds
Afdo creates more variants to build, and optimizing LTO is costly to
perform. Turn off these two optimizations for eng builds for a faster
build speed.

This reduces total C/C++ invocation time for aosp_arm64-eng by 6.28%.

Test: presubmit
Bug: 307753064
Change-Id: Ibac4269c66a64e896dba2074b607d71a2da37546
2023-12-04 19:04:00 +09:00
Yi Kong
0880a82de5 Revert "afdo: Remove -fprofile-sample-accurate flag"
This reverts commit febf8b9bdf.

We are still seeing flaky performance alerts from microbenchmarks even
with this change, and this has caused binary size / memory usage
increase. Let's add this flag back and observe whether performance
regression reports become more frequent.

Change-Id: I0fec1296b1f49b21b59d81add677f6a926ee88dc
2023-11-15 08:51:08 +09:00
Yi Kong
bc2d02aa6a Add additional flag required for Flow Sensitive AFDO
It can be removed in the future once it becomes default.

Test: presubmit
Bug: 304282732
Change-Id: Ia7729593eff13ba5cc69fdb54519305295313b4d
2023-10-16 16:59:21 +09:00
Yi Kong
b33ced051a Enable Flow Sensitive AutoFDO
FSAFDO (Flow Sensitive AutoFDO) is an improvement over AutoFDO. It
attempts to capture and represent the flow-sensitive profile in LLVM
optimization passes with the mechanism to expose and iteratively
reload/match the profile with better precision.

Enable this for all AFDO projects so that we can capture data from the
field, and then evaluate the performance gain.

Test: presubmit
Bug: 304282732
Change-Id: I0de6b4071e4f0a75500f3ffd5171a7be5117ec86
2023-10-10 14:16:29 +09:00
Yi Kong
2dbe160d1a Do not enable AFDO if the option is off, even if there is a profile file
The behaviour is accidentally changed during the Bazel migration.

Test: m
Change-Id: I44158f2518776c68938ad2ddab01431005a333b0
2023-07-27 14:04:05 +09:00
Vinh Tran
056effb8b1 Add comment for afdo flag
Change-Id: If80df0ac0527784b13158325589c29587db8d5f9
Test: N/A
2023-07-05 15:48:21 +00:00
Yi Kong
febf8b9bdf afdo: Remove -fprofile-sample-accurate flag
-fprofile-sample-accurate allows the compiler to de-optimize cold code
paths according to the profile. However we have a number of micro-
benchmarks that tests these paths and we often trigger regression
reports from those benchmarks.

Turning off the flag mitigates the issue at a cost of ~2MB increase in
system image size. But the more deterministic codegen could reduce the
differential OTA size.

Test: presubmit
Bug: 283235002
Change-Id: I1016f573f21a60223a97c64f5818f0e7e66e41e3
2023-06-06 08:27:47 +00:00
Yabin Cui
01c4456ce2 Enable -funique-internal-linkage-names when afdo=true
We used to enable unique names only when a profile is available.
But A profile generated for a binary without unique names doesn't
work well when building a binary with unique names. To avoid a
chicken-and-egg problem, this CL enables the flag when afdo=true,
whether a profile exists or not.

Bug: 241523910
Test: build
Change-Id: I74d834510d81d2db76e34d0488c74a60e1fcecd5
2023-04-21 14:41:55 -07:00
Yi Kong
a1961e7eed Prepend AFDO flags to allow overriding
This enables turnning off -fprofile-sample-accurate on a per project
basis.

Bug: 274725934
Bug: 273415627
Test: presubmit
Change-Id: I15060950f7b55e51069cb00b66512c7e94981f1b
2023-04-05 11:49:19 +09:00
Vinh Tran
cde1016aff Reimplement afdo support for rust
Ignore-AOSP-First: The parent CL is internal
Bug: 267229065
Test: go test
Change-Id: Ia14679285b92f3f14ff269392a61f978c71311b2
Merged-In: Ia14679285b92f3f14ff269392a61f978c71311b2
2023-03-31 17:55:16 -04:00
Vinh Tran
44cb78c988 Implement fdo_profile module type
Introducing fdo_profile module type to reimplement the afdo support in cc moduels. This change allows the feature to be compatible with Bazel migration.

How it works:

PreDepsMutators:
  * BeginMutator: If non-static cc modules sets afdo prop, search and add corresponding fdo_profile module as a dep with fdoProfileTag
  * fdoProfileMutator:
    * If in fdo_profile module, set FdoProfileProvider with full path to profile
    * If in cc module, read FdoProfileProvider from dep with fdoProfileTag and set FdoProfileInfo.Path to FdoProfilePath field

PostDepsMutators:
  * afdoDepsMutator: If a module has FdoProfilePath set, walk to its static deps and set itself to the deps' AfdoRdeps
  * afdoMutator: If a static dep has AfdoRDeps set, create afdo variant.

Ignore-AOSP-First: Other CLs in the same topic are internal-only
Test: go test
Bug: b/267229065
Change-Id: I687d798a02d9743c92804fea36fb4ae3a7a0e5e3
Merged-In: I687d798a02d9743c92804fea36fb4ae3a7a0e5e3
2023-03-31 17:52:01 -04:00
Vinh Tran
7a8362c252 Remove AfdoAdditionalProfileDirs product variable
AfdoAdditionalProfileDirs is unconnected to build/make/core/soong_config.mk and is currently unused. Removing AfdoAdditionalProfileDirs will cut down on complexity when we migrate the support of auto-fdo profiles to Bazel cc rules.

b/258684450 proposes an alternative to support the use cases that were meant to be supported by AfdoAdditionalProfileDirs.

Test: existing go tests
Bug: 253540178
Change-Id: I024e48598a560717a1d6c19b16bde3fe65ff1961
2022-11-11 03:29:31 +00:00
Colin Cross
d079e0b270 Reformat build/soong for go 1.19
Test: none
Change-Id: I132368f0fcbdb5ea088b5b84dbe4ccfdd9e94cad
2022-08-17 10:43:13 -07:00
Alix
40216ae88b moved comment to describe Afdo bool
Test: just added a comment, no tests performed.

Change-Id: Id921b808462600e889ee8fda532a3305821692b2
2022-04-08 18:57:30 +00:00
Yi Kong
71198ac516 Turn on Unique Internal Names for AFDO
AutoFDO uses a function’s symbol name to look up profile data but
functions with internal linkages do not have globally unique
identifiers. This can lead to name conflicts leading to missing profiles
and performance. We are enabling compiler option
-funique-internal-linkage-names for AFDO builds that will uniquefy
internal linkage symbols making this problem go away.

This CL might regress the performance due to mismatched profiles. It
will recover once we update the profiles.

Test: presubmit
Bug: 218448389
Change-Id: I92a2b6f72b52faab79aec9148f1962111bad7232
2022-02-10 08:09:38 +00:00
Yi Kong
88e632e263 Allow static binaries to enable AFDO
The static() property is true for both static libraries and static
binaries. We should allow static binaries to enable AFDO.

Test: Enable AFDO for linker
Change-Id: I409fc9f764ea878f01dc42bb2e5c075219403009
2022-01-25 05:22:01 +00:00
Yi Kong
46c6e59415 AFDO for Rust
Bug: 195134194
Bug: 165018530
Test: build
Change-Id: I30932a22dc0b22716cdc925a3fcc5f9a169fcec4
2022-01-21 18:13:18 +08:00
Yi Kong
eb8efc902d Introduce afdo
A new configuration rule for sampling PGO. This differs from the
original pgo.go rule in the following ways:
 * Automatic propagation to static dependencies
 * Simpler configuration (just put `afdo: true` to optimsation targets)

http://go/android-afdo

Test: build
Bug: 79161490
Change-Id: Ie194824cd523bca19e10ced41d2078fc598f13b3
2021-12-21 16:09:23 +08:00