Skip to content

Commit

Permalink
Small baseline profile generation tweaks (#1260)
Browse files Browse the repository at this point in the history
Just aligning some stuff from our other projects and small updates
  • Loading branch information
ZacSweers authored May 13, 2024
1 parent 5de4dc4 commit 1be3dbe
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 25 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/update-baseline-profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Update Baseline Profiles"

on:
workflow_dispatch:
# Always run on PRs if this file was modified! We won't PR changes if we modify the file though
# Always run on PRs if this file was modified
pull_request:
paths:
- '.github/workflows/update-baseline-profiles.yml'
Expand Down Expand Up @@ -36,6 +36,13 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Update SDK
run: |
echo "Accepting SDK licenses"
yes | "${ANDROID_HOME}"/cmdline-tools/latest/bin/sdkmanager --licenses || true
echo "Installing emulator image"
"${ANDROID_HOME}"/cmdline-tools/latest/bin/sdkmanager --install "system-images;android-33;google_apis;x86_64"
- name: Generate baseline profiles
run: ./scripts/update-baseline-profiles.sh

Expand Down
2 changes: 2 additions & 0 deletions samples/star/apk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ android {
)
}
}
experimentalProperties["android.experimental.art-profile-r8-rewriting"] = true
experimentalProperties["android.experimental.r8.dex-startup-optimization"] = true
}

baselineProfile {
Expand Down
49 changes: 33 additions & 16 deletions samples/star/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ plugins {
alias(libs.plugins.baselineprofile)
}

val mvdApi = 33
val mvdName = "pixel6Api$mvdApi"
val isCi = providers.environmentVariable("CI").isPresent

android {
namespace = "com.circuit.samples.star.benchmark"
defaultConfig {
Expand All @@ -16,34 +20,47 @@ android {
}

testOptions.managedDevices.devices {
create<ManagedVirtualDevice>("pixel6Api31") {
create<ManagedVirtualDevice>(mvdName) {
device = "Pixel 6"
apiLevel = 31
systemImageSource = "aosp"
apiLevel = mvdApi
systemImageSource = "google"
}
}

targetProjectPath = ":samples:star:apk"
// Load the target app in a separate process so that it can be restarted multiple times, which
// is necessary for startup benchmarking to work correctly.
// https://source.android.com/docs/core/tests/development/instr-self-e2e
experimentalProperties["android.experimental.self-instrumenting"] = true
experimentalProperties["android.experimental.testOptions.managedDevices.setupTimeoutMinutes"] = 20
// TODO remove in AGP 8.2
experimentalProperties["android.experimental.androidTest.numManagedDeviceShards"] = 1
experimentalProperties["android.experimental.testOptions.managedDevices.maxConcurrentDevices"] = 1
experimentalProperties[
"android.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules"] =
"baselineprofile"
// TODO enable in AGP 8.2, doesn't work in AGP 8.1
// experimentalProperties["android.experimental.art-profile-r8-rewriting"] = true
"android.experimental.testOptions.managedDevices.emulator.showKernelLogging"] = true
// If on CI, add indirect swiftshader arg
if (isCi) {
experimentalProperties["android.testoptions.manageddevices.emulator.gpu"] =
"swiftshader_indirect"
}
}

val useConnectedDevice =
providers.gradleProperty("catchup.benchmark.useConnectedDevice").getOrElse("false").toBoolean()

baselineProfile {
// This specifies the managed devices to use that you run the tests on. The default
// is none.
managedDevices += "pixel6Api31"
// This specifies the managed devices to use that you run the tests on. The
// default is none.
if (!useConnectedDevice) {
managedDevices += mvdName
}

// This enables using connected devices to generate profiles. The default is true.
// When using connected devices, they must be rooted or API 33 and higher.
useConnectedDevices = false
// This enables using connected devices to generate profiles. The default is
// true. When using connected devices, they must be rooted or API 33 and
// higher.
useConnectedDevices = useConnectedDevice

// Set to true to see the emulator, useful for debugging. Only enabled locally
enableEmulatorDisplay = false
// Disable the emulator display for GMD devices on CI
enableEmulatorDisplay = !isCi
}

dependencies {
Expand Down
10 changes: 2 additions & 8 deletions scripts/update-baseline-profiles.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/usr/bin/env bash
set -uo pipefail

# If on CI, add indirect swiftshader arg
gpu_arg=" "
if [[ "${CI:-}" == "true" ]]; then
gpu_arg="-Pandroid.testoptions.manageddevices.emulator.gpu=swiftshader_indirect"
fi

# TODO --unused-only flag for cleaning can't be used because devices appear to be left in a bad state
./gradlew cleanManagedDevices && ./gradlew generateBaselineProfile $gpu_arg
./gradlew cleanManagedDevices --unused-only
./gradlew generateBaselineProfile

0 comments on commit 1be3dbe

Please sign in to comment.