Skip to content

Conversation

@Laimiux
Copy link
Collaborator

@Laimiux Laimiux commented Dec 1, 2025

What

Adding official support for R8 optimizations for formula

  • Adds proguard meta file to formula.jar
  • Adding instrumentation test with R8 enabled to ensure that it works.

@Laimiux Laimiux force-pushed the laimonas/r8-tests branch 3 times, most recently from a2fd5a5 to 5cafdb7 Compare December 2, 2025 15:07
@carrotkite
Copy link

JaCoCo Code Coverage 93.98% ✅

Class Covered Meta Status

Generated by 🚫 Danger

@carrotkite
Copy link

carrotkite commented Dec 2, 2025

📊 Benchmark Comparison Report

Summary

  • Regressions: 0 ✅
  • Improvements: 0
  • Unchanged: 25
No significant changes (25 benchmarks)
Benchmark Baseline Current Change
com.instacart.formula.benchmarks.ActionCountBenchmark.stateChanges (actionCount=1) 12.87 ± 0.146 us/op 12.89 ± 0.159 us/op +0.1%
com.instacart.formula.benchmarks.ActionCountBenchmark.stateChanges (actionCount=100) 15.325 ± 0.107 us/op 15.433 ± 0.276 us/op +0.7%
com.instacart.formula.benchmarks.ActionCountBenchmark.stateChanges (actionCount=25) 13.431 ± 0.19 us/op 13.369 ± 0.134 us/op -0.5%
com.instacart.formula.benchmarks.ActionInitializationBenchmark.initializeNewActions (actionCount=1) 0.71 ± 0.047 us/op 0.726 ± 0.072 us/op +2.2%
com.instacart.formula.benchmarks.ActionInitializationBenchmark.initializeNewActions (actionCount=100) 16.877 ± 0.24 us/op 17.493 ± 0.871 us/op +3.6%
com.instacart.formula.benchmarks.ActionInitializationBenchmark.initializeNewActions (actionCount=25) 4.365 ± 0.026 us/op 4.426 ± 0.168 us/op +1.4%
com.instacart.formula.benchmarks.CallbackInitializationBenchmark.initializeNewCallbacks (callbackCount=10) 2.247 ± 0.337 us/op 2.311 ± 0.515 us/op +2.8%
com.instacart.formula.benchmarks.CallbackInitializationBenchmark.initializeNewCallbacks (callbackCount=50) 9.249 ± 3.025 us/op 8.942 ± 1.623 us/op -3.3%
com.instacart.formula.benchmarks.CallbackOverheadBenchmark.transitions (callbackCount=10) 13.152 ± 0.166 us/op 13.19 ± 0.122 us/op +0.3%
com.instacart.formula.benchmarks.CallbackOverheadBenchmark.transitions (callbackCount=50) 14.671 ± 0.551 us/op 14.728 ± 0.62 us/op +0.4%
com.instacart.formula.benchmarks.ChildrenCountBenchmark.stateChanges (childrenCount=1) 12.72 ± 0.148 us/op 12.936 ± 0.201 us/op +1.7%
com.instacart.formula.benchmarks.ChildrenCountBenchmark.stateChanges (childrenCount=100) 14.376 ± 0.199 us/op 14.434 ± 0.112 us/op +0.4%
com.instacart.formula.benchmarks.ChildrenCountBenchmark.stateChanges (childrenCount=25) 13.189 ± 0.216 us/op 13.119 ± 0.132 us/op -0.5%
com.instacart.formula.benchmarks.ChildrenInitializationBenchmark.initializeNewChildren (childrenCount=1) 0.679 ± 0.055 us/op 0.685 ± 0.056 us/op +0.8%
com.instacart.formula.benchmarks.ChildrenInitializationBenchmark.initializeNewChildren (childrenCount=100) 11.548 ± 0.315 us/op 11.723 ± 0.179 us/op +1.5%
com.instacart.formula.benchmarks.ChildrenInitializationBenchmark.initializeNewChildren (childrenCount=25) 3.353 ± 0.042 us/op 3.332 ± 0.069 us/op -0.6%
com.instacart.formula.benchmarks.GlobalEffectQueueBenchmark.measure100Effects 8.057 ± 0.1 us/op 8.372 ± 0.087 us/op +3.9%
com.instacart.formula.benchmarks.GlobalEffectQueueBenchmark.measure10Effects 0.658 ± 0.03 us/op 0.685 ± 0.009 us/op +4.1%
com.instacart.formula.benchmarks.GlobalEffectQueueBenchmark.measure1Effect 0.051 ± 0.0 us/op 0.051 ± 0.0 us/op +0.2%
com.instacart.formula.benchmarks.TransitionBenchmark.transitions (depth=0) 12.675 ± 0.164 us/op 12.739 ± 0.115 us/op +0.5%
com.instacart.formula.benchmarks.TransitionBenchmark.transitions (depth=10) 12.855 ± 0.095 us/op 12.98 ± 0.231 us/op +1.0%
com.instacart.formula.benchmarks.TransitionBenchmark.transitions (depth=20) 13.385 ± 0.098 us/op 13.503 ± 0.078 us/op +0.9%
com.instacart.formula.benchmarks.TransitionQueueBenchmark.measure1 0.345 ± 0.007 us/op 0.329 ± 0.003 us/op -4.6%
com.instacart.formula.benchmarks.TransitionQueueBenchmark.measure100 0.348 ± 0.013 us/op 0.347 ± 0.013 us/op -0.3%
com.instacart.formula.benchmarks.TransitionQueueBenchmark.measure10000 0.341 ± 0.005 us/op 0.35 ± 0.017 us/op +2.6%

Regression threshold: ±10% with non-overlapping confidence intervals

Generated by 🚫 Danger

@@ -0,0 +1,72 @@
name: R8 Integration Tests
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running emulator tests on github CI

@Laimiux Laimiux force-pushed the laimonas/r8-tests branch 2 times, most recently from 24062b9 to fc5e784 Compare December 2, 2025 20:03

object AbstractClassInheritanceFormulas {

class One : ActionFormula<Unit, Int>() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both One and Two extend ActionFormula. In our test, we want to make sure that IFormula.type() implementation is not modified by R8.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the primary issue that I noticed with fullMode=true enabled

@Laimiux Laimiux force-pushed the laimonas/r8-tests branch 2 times, most recently from bf0dcf7 to 1587859 Compare December 2, 2025 20:28
@Laimiux Laimiux changed the title Test R8 optimizations. Enable R8 optimizations. Dec 2, 2025
@@ -0,0 +1,70 @@
plugins {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuring tests with R8 enabled

@@ -0,0 +1,9 @@
# Formula R8/ProGuard Rules
Copy link
Collaborator Author

@Laimiux Laimiux Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be packaged with the jar. Without this, the test fails with

com.instacart.formula.r8.FormulaR8Test > actionFormulas[Medium_Phone_API_36.1(AVD) - 16] FAILED 
        R.a: Formula class S.a with a key FormulaKey(scopeKey=null, type=class S.a, key=kotlin.Unit) already requested by class com.instacart.formula.r8.interactors.AbstractFormulaTypeInheritanceInteractor$formula$1
        at Q.e.a(SourceFile:74)
Tests on Medium_Phone_API_36.1(AVD) - 16 failed: There was 1 failure(s).

Copy link

@jasonostrander jasonostrander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Laimiux Laimiux merged commit e565790 into master Dec 2, 2025
11 checks passed
@Laimiux Laimiux deleted the laimonas/r8-tests branch December 2, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants