Skip to content

Commit 4f4761b

Browse files
committed
Merge remote-tracking branch 'origin/main' into ray/last-up-merge
* origin/main: Do not build & upload mobile.dev if no secret Update sample workflow_version to 1.7.1 Finish releasing v1.7.1 Releasing v1.7.1 Backports BackStackContainer view persistence fix Creating 1.7 fix branch. Backports BackStackContainer view persistence fix Report Fully Drawn from PerformancePoetryActivity Upload Poetry APK to mobile.dev and start analysis Add Baseline Gathering and Perf Benchmarks to Complex Poetry use --no-daemon for both Gradle commands in publish-snapshot action
2 parents 738b79e + 0f0c0cf commit 4f4761b

File tree

34 files changed

+1287
-139
lines changed

34 files changed

+1287
-139
lines changed

.github/workflows/kotlin.yml

Lines changed: 139 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
name: Kotlin CI
1+
name : Kotlin CI
22

3-
on:
4-
push:
5-
branches:
3+
on :
4+
push :
5+
branches :
66
- main
7-
pull_request:
8-
paths-ignore:
7+
pull_request :
8+
paths-ignore :
99
# Don't build the entire app when just changing tutorials, which have their own workflow.
1010
- 'samples/tutorial/**'
1111

12-
jobs:
12+
jobs :
1313

14-
cancel-stale-jobs:
15-
runs-on: ubuntu-latest
16-
steps:
14+
cancel-stale-jobs :
15+
runs-on : ubuntu-latest
16+
steps :
1717
# If CI is already running for a branch when that branch is updated, cancel the older jobs.
18-
- name: Cancel Stale Jobs
19-
uses: styfle/[email protected]
20-
env:
21-
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
22-
23-
dokka:
24-
name: Assemble & Dokka
25-
runs-on: ubuntu-latest
26-
timeout-minutes: 20
27-
steps:
28-
- uses: actions/checkout@v2
29-
- name: set up JDK 11.0.7
30-
uses: actions/setup-java@v1
31-
with:
32-
java-version: 11.0.7
18+
- name : Cancel Stale Jobs
19+
uses : styfle/[email protected]
20+
env :
21+
GITHUB_TOKEN : '${{ secrets.GITHUB_TOKEN }}'
22+
23+
dokka :
24+
name : Assemble & Dokka
25+
runs-on : ubuntu-latest
26+
timeout-minutes : 20
27+
steps :
28+
- uses : actions/checkout@v2
29+
- name : set up JDK 11.0.7
30+
uses : actions/setup-java@v1
31+
with :
32+
java-version : 11.0.7
3333

3434
## Actual task
3535
- uses : burrunan/gradle-cache-action@v1
@@ -59,17 +59,17 @@ jobs:
5959
gradle-distribution-sha-256-sum-warning : false
6060

6161
# These are all pretty quick so we run them on a single shard. Fewer shards, less queueing.
62-
check:
63-
name: Check
64-
runs-on: ubuntu-latest
65-
timeout-minutes: 20
66-
steps:
67-
- uses: actions/checkout@v2
68-
- uses: gradle/wrapper-validation-action@v1
69-
- name: set up JDK 11.0.7
70-
uses: actions/setup-java@v1
71-
with:
72-
java-version: 11.0.7
62+
check :
63+
name : Check
64+
runs-on : ubuntu-latest
65+
timeout-minutes : 20
66+
steps :
67+
- uses : actions/checkout@v2
68+
- uses : gradle/wrapper-validation-action@v1
69+
- name : set up JDK 11.0.7
70+
uses : actions/setup-java@v1
71+
with :
72+
java-version : 11.0.7
7373

7474
## Actual task
7575
- uses : burrunan/gradle-cache-action@v1
@@ -83,24 +83,24 @@ jobs:
8383
gradle-build-scan-report : false
8484
gradle-distribution-sha-256-sum-warning : false
8585

86-
instrumentation-tests:
87-
name: Instrumentation tests
88-
runs-on: macos-latest
89-
timeout-minutes: 45
90-
strategy:
86+
instrumentation-tests :
87+
name : Instrumentation tests
88+
runs-on : macos-latest
89+
timeout-minutes : 45
90+
strategy :
9191
# Allow tests to continue on other devices if they fail on one device.
92-
fail-fast: false
93-
matrix:
94-
api-level:
92+
fail-fast : false
93+
matrix :
94+
api-level :
9595
- 29
9696
# Unclear that older versions actually honor command to disable animation.
9797
# Newer versions are reputed to be too slow: https://github.com/ReactiveCircus/android-emulator-runner/issues/222
98-
steps:
99-
- uses: actions/checkout@v2
100-
- name: set up JDK 11.0.7
101-
uses: actions/setup-java@v1
102-
with:
103-
java-version: 11.0.7
98+
steps :
99+
- uses : actions/checkout@v2
100+
- name : set up JDK 11.0.7
101+
uses : actions/setup-java@v1
102+
with :
103+
java-version : 11.0.7
104104

105105
## Build before running tests, using cache.
106106
- uses : burrunan/gradle-cache-action@v1
@@ -115,19 +115,94 @@ jobs:
115115
gradle-distribution-sha-256-sum-warning : false
116116

117117
## Actual task
118-
- name: Instrumentation Tests
119-
uses: reactivecircus/android-emulator-runner@v2
120-
with:
118+
- name : Instrumentation Tests
119+
uses : reactivecircus/android-emulator-runner@v2
120+
with :
121121
# @ychescale9 suspects Galaxy Nexus is the fastest one
122-
profile: Galaxy Nexus
123-
api-level: ${{ matrix.api-level }}
124-
arch: x86_64
122+
profile : Galaxy Nexus
123+
api-level : ${{ matrix.api-level }}
124+
arch : x86_64
125125
# Skip the benchmarks as this is running on emulators
126-
script: ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedReleaseAndroidTest --no-daemon --stacktrace
127-
128-
- name: Upload results
129-
if: ${{ always() }}
130-
uses: actions/upload-artifact@v2
131-
with:
132-
name: instrumentation-test-results-${{ matrix.api-level }}
133-
path: ./**/build/reports/androidTests/connected/**
126+
script : ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck --no-daemon --stacktrace
127+
128+
- name : Upload results
129+
if : ${{ always() }}
130+
uses : actions/upload-artifact@v2
131+
with :
132+
name : instrumentation-test-results-${{ matrix.api-level }}
133+
path : ./**/build/reports/androidTests/connected/**
134+
135+
upload-to-mobiledev :
136+
name : mobile.dev | Build & Upload
137+
runs-on : ubuntu-latest
138+
timeout-minutes : 20
139+
steps :
140+
- uses : actions/checkout@v2
141+
142+
- name : set up JDK 11.0.7
143+
if : env.MOBILE_DEV_API_KEY != null
144+
uses : actions/setup-java@v1
145+
with :
146+
java-version : 11.0.7
147+
env :
148+
MOBILE_DEV_API_KEY : ${{ secrets.MOBILE_DEV_API_KEY }}
149+
150+
151+
## Build artifact for upload with cache
152+
- uses : burrunan/gradle-cache-action@v1
153+
name : Build Performance Poetry APK
154+
if : env.MOBILE_DEV_API_KEY != null
155+
with :
156+
gradle-dependencies-cache-key : |
157+
gradle/libs.versions.toml
158+
arguments : |
159+
benchmarks:performance-poetry:complex-poetry:assembleRelease --no-daemon --stacktrace
160+
concurrent : true
161+
gradle-build-scan-report : false
162+
gradle-distribution-sha-256-sum-warning : false
163+
env :
164+
MOBILE_DEV_API_KEY : ${{ secrets.MOBILE_DEV_API_KEY }}
165+
166+
## Upload with POST
167+
- name : Upload Poetry to mobile.dev
168+
if : env.MOBILE_DEV_API_KEY != null
169+
id : upload_apk
170+
run : |
171+
#!/usr/bin/env bash
172+
set -e
173+
set -x
174+
RESPONSE_ID=$(curl -X POST \
175+
-H 'Content-Type: multipart/form-data' \
176+
-H "Authorization: Bearer $MOBILE_DEV_API_KEY" \
177+
--data-binary "@$APP_FILE" \
178+
https://api.mobile.dev/apk | jq -r .id)
179+
echo "::set-output name=apk_id::$RESPONSE_ID"
180+
env :
181+
MOBILE_DEV_API_KEY : ${{ secrets.MOBILE_DEV_API_KEY }}
182+
APP_FILE : benchmarks/performance-poetry/complex-poetry/build/outputs/apk/release/complex-poetry-release.apk
183+
184+
## Start analysis
185+
- name : Start analysis on mobile.dev
186+
if : env.MOBILE_DEV_API_KEY != null
187+
run : |
188+
#!/usr/bin/env bash
189+
set -e
190+
set -x
191+
GIT_HASH=$(git log --pretty=format:'%h' -n 1)
192+
BENCHMARK_NAME="$GIT_HASH"
193+
REPO_BASE_NAME=$(basename "$REPO_NAME")
194+
if [[ ! -z "$PULL_REQUEST_ID" ]]; then
195+
PR_DATA=", \"repoOwner\":\"$REPO_OWNER\", \"repoName\":\"$REPO_BASE_NAME\", \"pullRequestId\":\"$PULL_REQUEST_ID\""
196+
fi
197+
curl -X POST \
198+
-H "Content-Type: application/json" \
199+
-H "Authorization: Bearer $MOBILE_DEV_API_KEY" \
200+
https://api.mobile.dev/analysis \
201+
--data "{\"benchmarkName\": \"$BENCHMARK_NAME\", \"apkId\": \"$APP_ID\", \"branch\": \"$BRANCH_NAME\"$PR_DATA}"
202+
env :
203+
APP_ID : ${{ steps.upload_apk.outputs.apk_id }}
204+
MOBILE_DEV_API_KEY : ${{ secrets.MOBILE_DEV_API_KEY }}
205+
REPO_OWNER : ${{ github.repository_owner }}
206+
REPO_NAME : ${{ github.repository }}
207+
BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
208+
PULL_REQUEST_ID : ${{ github.event.pull_request.number }}

.github/workflows/publish-snapshot.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ jobs:
2222
java-version: 11.0.7
2323

2424
- name : Publish Snapshots
25-
run: ./gradlew clean build && ./gradlew publish --no-parallel --no-daemon
25+
run: |
26+
./gradlew clean build --no-daemon
27+
./gradlew publish --no-parallel --no-daemon
2628
env :
2729
ORG_GRADLE_PROJECT_mavenCentralUsername : ${{ secrets.SONATYPE_NEXUS_USERNAME }}
2830
ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.SONATYPE_NEXUS_PASSWORD }}

RELEASING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
1. Confirm that the kotlin build is green before committing any changes
99
(Note we exclude benchmarks, but you can check those too!)
1010
```bash
11-
./gradlew build && ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck
11+
./gradlew build && ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck
1212
```
1313

1414
1. Update your tags.

benchmarks/README.md

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
# benchmarks
22

3-
This module contains benchmarks. Used to measure and help improve Workflow performance. These tests
4-
should be run on physical devices.
3+
This module contains benchmarks. Used to measure and help improve Workflow performance. The
4+
deterministic tests - such as those for render passes - can be run on any device (virtual or
5+
otherwise), but the benchmarks should be run on physical devices, or the closest approximation
6+
to physical devices you can get.
57

6-
## dungeon-benchmark
8+
## Baseline Profiles
9+
10+
The sample apps can be used to extract 'baseline profiles' to improve code loading time after first
11+
install. See [baseline profiles](https://developer.android.com/studio/profile/baselineprofiles).
12+
13+
We can use
14+
[dungeon](dungeon-benchmark/src/main/java/com/squareup/sample/dungeon/benchmark/DungeonGatherBaselineProfile.kt)
15+
or [performance-poetry](performance-poetry/complex-benchmark/src/main/java/com/squareup/benchmarks/performance/poetry/complex/benchmark/ComplexPoetryGatherBaseline.kt)
16+
to gather profiles. Performance Poetry has more adaptability and better benchmarks at this time, so
17+
focus on that.
718

8-
This is for the /samples/dungeon/app. This includes a macrobenchmark
9-
[test](dungeon-benchmark/src/main/java/com/squareup/sample/dungeon/benchmark/WorkflowBaselineProfiles.kt)
10-
that exercises this sample app (with UiAutomator) to collect
11-
a [baseline profile](https://developer.android.com/studio/profile/baselineprofiles). After running
12-
this the `profile.txt` file can be taken off of the device and used directly in the /src/main
13-
directory of the application. This will include the profile into the APK for guided optimization at
14-
install time.
19+
After extracting the profile with one of those tests, the `profile.txt` file can be taken off of the
20+
device and used directly in the /src/main directory of the application. This will include the
21+
profile into the APK for guided optimization at install time.
1522

1623
Better yet, the profile can be split up and added into each Workflow module's src directory so that
1724
it will be included with all APKs built using Workflow (including 3rd party). To do this a java
18-
program available in the android-x open source [code](https://github.com/androidx/androidx) is used
19-
to split the profile based on src paths. That tool is found at
25+
program, available in the Android-X open source [code](https://github.com/androidx/androidx), is
26+
used to split the profile based on src paths. That tool is found at
2027
[androidx-main/frameworks/support/out/androidx/development/splitBaselineProfiles].
2128

2229
To split the profile paths for Workflow, the tool can be used as follows:
@@ -29,7 +36,22 @@ This will create an output file separated by module and then also by package as
2936
profile for each module can be added into its /src/main directory as `baseline-prof.txt`. Then on a
3037
release build this will be included with the resulting APK/binary.
3138

32-
The other [test](dungeon-benchmark/src/main/java/com/squareup/sample/dungeon/benchmark/WorkflowBaselineBenchmark.kt)
39+
## dungeon-benchmark
40+
41+
These are benchmarks for the [../samples/dungeon] app. Please instead use performance-poetry where
42+
possible.
43+
44+
*PLEASE NOTE:* The dungeon app includes AI ghosts with random travel which can 'eat' the player,
45+
ending the game with a dialog. This obviously makes these test non-deterministic. We used these
46+
originally to exercise enough of Workflow for a baseline profile. We can avoid at least the dialog
47+
popping to end the game by making the player survive with the following change to
48+
[../samples/dungeon/common/src/main/java/com/squareup/sample/dungeon/Game.kt]:
49+
50+
```kotlin
51+
val isPlayerEaten: Boolean get() = false // Never Eaten!
52+
```
53+
54+
The [benchmark](dungeon-benchmark/src/main/java/com/squareup/sample/dungeon/benchmark/DungeonStartupBenchmark.kt)
3355
is used to verify the results of including the baseline profiles on the startup time. This runs the
3456
same scenario with and without forcing the use of the profiles. To force the use of profiles, the
3557
`libs.androidx.profileinstaller` dependency is included into the app under profile (dungeon in this
@@ -41,11 +63,38 @@ Module of code for performance testing related to poetry applications.
4163

4264
### complex-poetry
4365

44-
This application is a modification of the samples/containers/app-poetry app which uses also the
66+
This application is a modified version of the samples/containers/app-poetry app which also uses the
4567
common components in samples/containers/common and samples/containers/poetry. It modifies this
4668
application to pass the Workflow
47-
a [SimulatedPerfConfig](performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/poetry/SimulatedPerfConfig.kt).
69+
a [SimulatedPerfConfig.](performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/instrumentation/SimulatedPerfConfig.kt)
4870

4971
In this case we specify that the app should be more 'complex' which adds delays into each of the
5072
selections that are run by Worker's which then trigger a loading state that is handled by the
51-
[MaybeLoadingGatekeeperWorkflow](performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/poetry/MaybeLoadingGatekeeperWorkflow.kt).
73+
[MaybeLoadingGatekeeperWorkflow.](performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/MaybeLoadingGatekeeperWorkflow.kt)
74+
75+
One benchmark that is included (and run in CI) as a UI test is the [RenderPassTest.](performance-poetry/complex-poetry/src/androidTest/java/com/squareup/benchmarks/performance/complex/poetry/RenderPassTest.kt)
76+
This measures two things:
77+
78+
1. The number of "Render Passes" that the Raven scenario triggers.
79+
1. The ratio of 'fresh renderings' to 'stale renderings' in the Raven scenario.
80+
81+
A rendering is 'fresh' if the node's state has changed. A rendering is 'stale' if its state is the
82+
same. Note that Workflow is designed to to have cheap, idempotent renderings and the fresh rendering
83+
ratio will never be 1.0 by design. However, if there are smells that have led to 'render churn' one
84+
will see a very poor rendering ratio and we would like a way to track that and to test that it is
85+
constant (or improving!).
86+
87+
This module includes an [instrumentation package](performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/instrumentation)
88+
that has two [WorkflowInterceptor]s that can count render passes or instrument perfetto Trace
89+
sections, as well as data class for tracking those.
90+
91+
This module also includes a [robots package](performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/robots)
92+
that provides some utility helper 'robots' for the UiAutomator [androidx.test.uiautomator.UiDevice]
93+
as well as scenarios specific to this Complex Poetry application.
94+
95+
### complex-benchmark
96+
97+
This is an Android Test module which hosts an application that can run androidx.macrobenchmarks.
98+
See the kdoc on [ComplexPoetryBenchmarks.](performance-poetry/complex-benchmark/src/main/java/com/squareup/benchmarks/performance/complex/poetry/benchmark/ComplexPoetryBenchmarks.kt)
99+
100+
The results for this are stored in the same folder at [ComplexPoetryResults.txt.](performance-poetry/complex-benchmark/src/main/java/com/squareup/benchmarks/performance/complex/poetry/benchmark/ComplexPoetryResults.txt)

0 commit comments

Comments
 (0)