Commit graph

16 commits

Author SHA1 Message Date
Pirama Arumuga Nainar
8aed42c798 Use a versioned profile file if available
Bug: http://b/74395273

Update profile-search logic to look for profile files named
<profile_file>.<arbitrary-version> in the profileProject and use that if
available.  This works around an issue where ccache serves stale cache
entries when the profile file has changed.

Test: touch toolchain/pgo-profiles/art/dex2oat.profdata.foo and check it
gets used.

Change-Id: I3de095c263b952cede25af7d0b63dc7280914d76
2018-03-09 16:05:54 +00:00
Colin Cross
32f3898f0b Remove unused intermediates parameter from ExistentPathForSource
Test: m checkbuild
Change-Id: Id2c0a5039c2ec3b3795385c135ffec022ccd691e
2018-02-22 14:43:36 -08:00
Yi Kong
7e53c57ed6 Disable inlining and loop unrolling in LTO without PGO profile
Such optimisations may significantly increase the binary size when
compiler heuristics are off. Disabling these helps cut down the
binary sizes with negligible decrease in performance, but allows us to
be more comfortable enabling LTO across various projects.

Test: m
Test: dex2oat, hwui, skia benchmark
Bug: 62839002
Change-Id: Id63e8dd295df2972f76ae4e29ee367080fff8429
2018-02-14 21:21:23 +08:00
Pirama Arumuga Nainar
49540800f0 Search for PGO profiles in PGO_ADDITIONAL_PROFILE_DIRS
This variable can be set in BoardConfig.mk to specify a list of
additional paths that contain PGO profiles.  These directories are
searched after the predefined paths in soong/cc/pgo.go while finding
PGO profiles.

Test: Set this variable in a BoardConfig and verify that such profiles
are found and that these paths are searched after the predefined paths
in soong/cc/pgo.go.

Change-Id: I0bb9523de614d0f23aba8d51c887d8fc8f41c993
2018-02-13 09:41:13 -08:00
Pirama Arumuga Nainar
28316d4e3b Store missing profile files into a Make variable
Bug: http://b/72642679

Store missing profile files and the modules that refer to them in the
SOONG_MODULES_MISSING_PGO_PROFILE_FILE variable passed to Make.  The
contents of this variable will be written to
$DIST_DIR/pgo_profile_file_missing.txt as part of the 'dist' target.

Test: 'm dist' and verify creation of pgo_profile_file_missing.txt.
Change-Id: I237cd0398be418be2b7db6fa65ece5ef347ecbc1
2018-01-29 10:02:27 -08:00
Pirama Arumuga Nainar
e236b5acfa Support instrumenting all PGO-enabled modules
Bug: http://b/63768402

If ANDROID_PGO_INSTRUMENT has "all" or "ALL", all PGO-enabled modules
are built for profile generation.

Test: Build with and without 'all' in ANDROID_PGO_INSTRUMENT
Change-Id: I3b1a9b562775e80a4ab3965100341d9e8e4ffde9
2018-01-22 20:26:16 -08:00
Pirama Arumuga Nainar
64946fec54 Update profile_file discovery rules
Bug: http://b/63768402

Profile files are searched in multiple directories in a pre-define list,
instead of just one.

PGO profile_file enforcement is also removed - profile_file dependency
and -fprofile-use are added iff the profile_file is present.

Test: Build https://android-review.googlesource.com/c/474805 with
.profdata files in vendor/google_data/pgo-profiles and
toolchain/pgo-profiles and verify expected behavior.

Change-Id: I2604713a8a7a682bd5c6bde569dc32335be5eca9
Merged-In: I2604713a8a7a682bd5c6bde569dc32335be5eca9
2018-01-18 10:26:34 -08:00
Pirama Arumuga Nainar
690ed55363 Add cflags sub-property to 'pgo'
This (possibly arch-specific) property adds extra flags while building
for profiling.  For example, dex2oat requires setting
'-Wno-frame-larger-than' when instrumentation is enabled.

Test: Build 'pgo' module with the new property and inspect build.ninja
Change-Id: Ia36422a400b0e0b87cbb33b1c8e565569475a56d
2017-12-13 17:48:33 -08:00
Colin Cross
6510f91a1c Replace ModuleContext.AConfig() with Config()
AConfig() now duplicates Config().  Replace the uses of AConfig()
with Config().  Leave AConfig() for now until code in other
projects is cleaned up.

Test: m checkbuild
Change-Id: Ic88be643049d21dba45dbd1a65588ed94bf43bdc
2017-11-30 00:44:18 +00:00
Pirama Arumuga Nainar
6aeed8b439 Add enable_profile_use property
Bug: http://b/65598278

This property defaults to 'true' and setting it to false skips profile
use.  This escape hatch lets us disable PGO for a module without
completely removing the 'pgo' property.  Additionally, this also helps
selectively disabling PGO for some architectures, if desired.

Test: Test that -fprofile-use is not added for a test module if
'enable_profile_use: false' is set.

Change-Id: Ifcf1a48c194bc86efd88a529cc2d66a47b7ab080
2017-10-16 13:36:29 -07:00
Pirama Arumuga Nainar
0fdfc459cf Do not use profiles if ANDROID_PGO_NO_PROFILE_USE is set
Bug: http://b/65598278

Non-PGO builds (with this environment variable set) can be used to
measure the performance difference induced by PGO.

Test: Build PGO modules with ANDROID_PGO_PROFILE_USE set.
Change-Id: Ib23bad5208ac7f54894c7768d7532f53b6b91179
2017-10-10 15:41:25 -07:00
Pirama Arumuga Nainar
3f5bb9c89b Refactor methods to be on PgoProperties struct
These methods only need the 'PgoProperties' struct.  Avoid the extra
indirection by directly using this struct.

Test: Build modules with PGO property.
Change-Id: I1923ebde4b0d546810de8e696514d218b3a4f54b
2017-10-10 10:58:37 -07:00
Pirama Arumuga Nainar
6fc8d9126c Check if "instrumentation" and "sampling" are set together
Setting these simultaneously is an error.

Test: Check error generation in a test module

Change-Id: I2ee127fa1b7157fa5f4489d2541ff023c64f9ba5
2017-10-05 10:33:57 -07:00
Pirama Arumuga Nainar
49b53d5c7c Explicitly link the profile runtime during PGO
Bug: http://b/65598278

The profile runtime depends on libgcc for some symbols (only under some
circumstances - armv5, ndk r14, static executables).  Since Android
build passes -nostdlib and adds libgcc manually, the profile runtime
gets passed to the linker later than libgcc.

Instead, explicitly add the profile runtime to the linker command (and
pass one other flag added by the clang driver to the link).

Test: Build a library with profile instrumentation that otherwise fails
instrumented build.

Change-Id: I24b34cebd2c3bb6a540f8f4c465ace1be4eb90f3
Signed-off-by: Pirama Arumuga Nainar <pirama@google.com>
2017-10-04 22:25:19 -07:00
Pirama Arumuga Nainar
f4c0baf317 Pass -Wno-backend-plugin when using profiles
Bug: http://b/63768402

Wno-backend-plugin warnings are generated by IR-based PGO when sources
evolve and the profiles become stale.  Disable these warnings when
profiles are passed to the compiler.

Test: Build a module with a PGO property when profiles are used.
Change-Id: I462bbf55aafd8770a90c2c23462bf71607ac9108
2017-10-03 14:35:18 -07:00
Pirama Arumuga Nainar
ada83ec0a6 Add PGO support to soong
Bug: http://b/63768402
Bug: http://b/65598278

Add support for the 'pgo' property to specify how a module is processed
under PGO.  A sample property is below:

pgo: {
    instrumentation: true, // could be "sampling: true" when supported
    profile_file: "pgo_simple.profdata",
    benchmarks: ["pgo_simple"],
}

1. Runtime profiles can be gathered using "sampling" or
"instrumentation".  Sampling is not supported initially.

2. If 'toolchain/pgo-profiles' project is found,
'toolchain/pgo-profiles/${profile_file}' is passed to the compiler and
linker when building this module.

3. If ANDROID_PGO_INSTRUMENT environment variable is set, and includes a
benchmark in the 'benchmarks' list, appropriate flags (for e.g.
-fprofile-generate for instrumentation) are passed to the compiler and
linker when building this module.

Test: Add example modules that specify the pgo property and verify
appropriate flags and dependencies in the Ninja file.  Some
tests/examples are in https://android-review.googlesource.com/474805

Change-Id: I6242e0c904497a115e367dea6927ba1c4b906355
2017-09-21 12:37:19 -07:00