Skip to content

Commit 2fab83d

Browse files
Runtime Optimization: Process all actions possible within 30ms frame rate
Runtime will keep processing actions that do not produce output until the frame timeout of 30ms. This is an abitrary value and (TODO) we should connect it with the Choreographer frame clock in similar way to how molecule does it with the AndroidUiDispatcher.Main and its frame clock. Tests are modified for when using the optimized runtime in order to wait past the timeout. We add expect fun currentTimeMillis() to the common code to get epoch millis on all platforms. Added RuntimeConfig utilities for JVM and Android Apps to run tests or build apps with each different runtime. Separate shard for different runtime.
1 parent 35d9232 commit 2fab83d

File tree

86 files changed

+2884
-950
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2884
-950
lines changed

.github/workflows/kotlin.yml

Lines changed: 136 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,42 @@ jobs :
9292
with :
9393
report_paths : '**/build/test-results/test/TEST-*.xml'
9494

95+
jvm-timeout-runtime-test:
96+
name: Frame Timeout Runtime JVM Tests
97+
runs-on : ubuntu-latest
98+
timeout-minutes : 20
99+
steps :
100+
- uses : actions/checkout@v3
101+
- uses : gradle/wrapper-validation-action@v1
102+
- name : set up JDK 11
103+
uses : actions/setup-java@v3
104+
with :
105+
distribution: 'zulu'
106+
java-version : 11
107+
108+
## Actual task
109+
- uses : burrunan/gradle-cache-action@v1
110+
name : Check with Gradle
111+
with :
112+
gradle-dependencies-cache-key : |
113+
gradle/libs.versions.toml
114+
arguments : |
115+
jvmTest --no-daemon --stacktrace --continue -Pworkflow.runtime=timeout
116+
concurrent : true
117+
gradle-build-scan-report : false
118+
gradle-distribution-sha-256-sum-warning : false
119+
120+
# Report as Github Pull Request Check.
121+
- name : Publish Test Report
122+
uses : mikepenz/action-junit-report@v3
123+
if : always() # always run even if the previous step fails
124+
with :
125+
report_paths : '**/build/test-results/test/TEST-*.xml'
126+
95127
ios-tests :
96128
name : iOS Tests
97129
runs-on : macos-latest
98-
timeout-minutes : 20
130+
timeout-minutes : 30
99131
steps :
100132
- uses : actions/checkout@v3
101133
- uses : gradle/wrapper-validation-action@v1
@@ -136,6 +168,56 @@ jobs :
136168
with :
137169
report_paths : '**/build/test-results/test/TEST-*.xml'
138170

171+
performance-tests :
172+
name : Performance tests
173+
runs-on : macos-latest
174+
timeout-minutes : 30
175+
strategy :
176+
# Allow tests to continue on other devices if they fail on one device.
177+
fail-fast : false
178+
matrix :
179+
api-level :
180+
- 29
181+
# Unclear that older versions actually honor command to disable animation.
182+
# Newer versions are reputed to be too slow: https://github.com/ReactiveCircus/android-emulator-runner/issues/222
183+
steps :
184+
- uses : actions/checkout@v3
185+
- name : set up JDK 11
186+
uses : actions/setup-java@v3
187+
with :
188+
distribution : 'zulu'
189+
java-version : 11
190+
191+
## Build before running tests, using cache.
192+
- uses : burrunan/gradle-cache-action@v1
193+
name : Build instrumented tests
194+
with :
195+
gradle-dependencies-cache-key : |
196+
gradle/libs.versions.toml
197+
arguments : |
198+
:benchmarks:performance-poetry:complex-poetry:assembleDebugAndroidTest --no-daemon --stacktrace
199+
concurrent : true
200+
gradle-build-scan-report : false
201+
gradle-distribution-sha-256-sum-warning : false
202+
203+
## Actual task
204+
- name : Render Pass Counting Test
205+
uses : reactivecircus/android-emulator-runner@v2
206+
with :
207+
# @ychescale9 suspects Galaxy Nexus is the fastest one
208+
profile : Galaxy Nexus
209+
api-level : ${{ matrix.api-level }}
210+
arch : x86_64
211+
# Skip the benchmarks as this is running on emulators
212+
script : ./gradlew :benchmarks:performance-poetry:complex-poetry:connectedCheck --no-daemon --stacktrace --continue
213+
214+
- name : Upload results
215+
if : ${{ always() }}
216+
uses : actions/upload-artifact@v3
217+
with :
218+
name : instrumentation-test-results-${{ matrix.api-level }}
219+
path : ./**/build/reports/androidTests/connected/**
220+
139221
instrumentation-tests :
140222
name : Instrumentation tests
141223
runs-on : macos-latest
@@ -177,7 +259,59 @@ jobs :
177259
api-level : ${{ matrix.api-level }}
178260
arch : x86_64
179261
# Skip the benchmarks as this is running on emulators
180-
script : ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck --no-daemon --stacktrace
262+
script : ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-poetry:connectedCheck --no-daemon --stacktrace
263+
264+
- name : Upload results
265+
if : ${{ always() }}
266+
uses : actions/upload-artifact@v3
267+
with :
268+
name : instrumentation-test-results-${{ matrix.api-level }}
269+
path : ./**/build/reports/androidTests/connected/**
270+
271+
frame-timeout-instrumentation-tests :
272+
name : Frame Timeout Instrumentation tests
273+
runs-on : macos-latest
274+
timeout-minutes : 45
275+
strategy :
276+
# Allow tests to continue on other devices if they fail on one device.
277+
fail-fast : false
278+
matrix :
279+
api-level :
280+
- 29
281+
# Unclear that older versions actually honor command to disable animation.
282+
# Newer versions are reputed to be too slow: https://github.com/ReactiveCircus/android-emulator-runner/issues/222
283+
steps :
284+
- uses : actions/checkout@v3
285+
- name : set up JDK 11
286+
uses : actions/setup-java@v3
287+
with :
288+
distribution : 'zulu'
289+
java-version : 11
290+
291+
## Build before running tests, using cache.
292+
- uses : burrunan/gradle-cache-action@v1
293+
name : Build instrumented tests
294+
with :
295+
gradle-dependencies-cache-key : |
296+
gradle/libs.versions.toml
297+
# Unfortunately I don't think we can key this cache based on our project property so
298+
# we clean and rebuild.
299+
arguments : |
300+
clean assembleDebugAndroidTest --no-daemon --stacktrace -Pworkflow.runtime=timeout
301+
concurrent : true
302+
gradle-build-scan-report : false
303+
gradle-distribution-sha-256-sum-warning : false
304+
305+
## Actual task
306+
- name : Instrumentation Tests
307+
uses : reactivecircus/android-emulator-runner@v2
308+
with :
309+
# @ychescale9 suspects Galaxy Nexus is the fastest one
310+
profile : Galaxy Nexus
311+
api-level : ${{ matrix.api-level }}
312+
arch : x86_64
313+
# Skip the benchmarks as this is running on emulators
314+
script : ./gradlew connectedCheck -x :benchmarks:dungeon-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-benchmark:connectedCheck -x :benchmarks:performance-poetry:complex-poetry:connectedCheck --no-daemon --stacktrace -Pworkflow.runtime=timeout
181315

182316
- name : Upload results
183317
if : ${{ always() }}

artifacts.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,22 @@
5555
"packaging": "jar",
5656
"javaVersion": "1.8"
5757
},
58+
{
59+
"gradlePath": ":workflow-config:config-android",
60+
"group": "com.squareup.workflow1",
61+
"artifactId": "workflow-config-android",
62+
"description": "Workflow Runtime Android Configuration",
63+
"packaging": "aar",
64+
"javaVersion": "1.8"
65+
},
66+
{
67+
"gradlePath": ":workflow-config:config-jvm",
68+
"group": "com.squareup.workflow1",
69+
"artifactId": "workflow-config-jvm",
70+
"description": "Workflow Runtime JVM Configuration",
71+
"packaging": "jar",
72+
"javaVersion": "1.8"
73+
},
5874
{
5975
"gradlePath": ":workflow-ui:compose",
6076
"group": "com.squareup.workflow1",

benchmarks/performance-poetry/complex-benchmark/src/main/java/com/squareup/benchmarks/performance/complex/poetry/benchmark/ComplexPoetryBenchmarks.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import org.junit.runner.RunWith
3131
* The above can be run as tests using Full, Partial, or No aot compiling on the app.
3232
*
3333
* For the rest of the benchmarks, see individual kdoc.
34+
*
35+
* Note that full benchmark suite without startup tests take 3hr+.
3436
*/
3537
@OptIn(ExperimentalMetricApi::class)
3638
@RunWith(AndroidJUnit4::class)
@@ -203,6 +205,7 @@ class ComplexPoetryBenchmarks {
203205
}
204206
putExtra(PerformancePoetryActivity.EXTRA_PERF_CONFIG_INITIALIZING, true)
205207
putExtra(PerformancePoetryActivity.EXTRA_PERF_CONFIG_ACTION_TRACING, true)
208+
putExtra(PerformancePoetryActivity.EXTRA_TRACE_SELECT_TIMEOUTS, true)
206209
}
207210
}
208211

@@ -278,17 +281,19 @@ class ComplexPoetryBenchmarks {
278281
const val PACKAGE_NAME = "com.squareup.benchmarks.performance.complex.poetry"
279282

280283
val ACTION_TRACE_SECTIONS = listOf(
281-
"E-PoemList-PoemSelected-00",
282-
"Worker-ComplexCallBrowser(2)-Finished-00",
283-
"E-StanzaList-StanzaSelected-00",
284-
"E-StanzaList-Exit-00",
285-
"Worker-ComplexCallBrowser(-1)-Finished-00",
284+
"E-PoemList-PoemSelected-${0.pad()}",
285+
"Worker-ComplexCallBrowser(2)-Finished-${0.pad()}",
286+
"E-StanzaList-StanzaSelected-${0.pad()}",
287+
"E-StanzaList-Exit-${0.pad()}",
288+
"Worker-ComplexCallBrowser(-1)-Finished-${0.pad()}",
286289
) + (0..11).map {
287290
"Worker-PoemLoading-Finished-${it.pad()}"
288291
} + (0..4).map {
289292
"E-StanzaWorkflow-ShowNextStanza-${it.pad()}"
290293
} + (0..4).map {
291294
"E-StanzaWorkflow-ShowPreviousStanza-${it.pad()}"
295+
} + (1..42).map {
296+
"E-Runtime-OnTimeout-${it.pad()}"
292297
}
293298

294299
val ACTION_TRACE_SECTIONS_HIGH_FREQUENCY = ACTION_TRACE_SECTIONS + (0..250).map {

0 commit comments

Comments
 (0)