raamcosta / compose-destinations

Annotation processing library for type-safe Jetpack Compose navigation with no boilerplate.
https://composedestinations.rafaelcosta.xyz
Apache License 2.0
3.23k stars 134 forks source link

Slow Gradle Build #702

Open nizam-betterapp opened 6 days ago

nizam-betterapp commented 6 days ago

Everytime we make a code change (eg: add a log line), kspDebugKotlin step takes 13 seconds and causes issues. Is this expected due to annotation library (or) is it supposed to be compiling incrementally? below is our gradle.properties Can you please help here how to enable ksp incremental build

org.gradle.jvmargs=-Xmx8g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -Dkotlin.daemon.jvm.options=-Xmx8g -XX:+HeapDumpOnOutOfMemoryError

org.gradle.jvmargs=-Xmx8g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -Dkotlin.daemon.jvm.options=-Xmx8g -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
kotlin.code.style=official
android.nonTransitiveRClass=true
android.nonFinalResIds=false
android.enableJetifier=false
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configureondemand=true
org.gradle.daemon=true
org.gradle.configuration-cache=true
org.gradle.configuration-cache.problems=warn
ksp.incremental=true
ksp.incremental.log=true
nizam-betterapp commented 5 days ago

I did the following and tried to figure out which library is not working with ksp incremental

Added these flags to track the dirty files

ksp.incremental=true
ksp.incremental.log=true

I commented compose destinations ksp line in build.gradle and ran the gradlew command

// ksp "io.github.raamcosta.compose-destinations:ksp:$raamcostaVersion"

./gradlew :app:kspDebugKotlin --scan

Dirty flag was perfect as below:

Dirty / All: 0.05%

Disappeared Outputs
Affected By CP
Affected By new syms
  src/main/java/ai/blox100/feature_zen_mode/presentation/bottom_sheet_end_session/ZenEndSessionViewModel.kt
  build/generated/ksp/debug/java/byRounds/1/ai/blox100/feature_zen_mode/presentation/bottom_sheet_end_session/ZenEndSessionViewModel_HiltModules.java
Affected By sealed
CP changes
Dirty:
  src/main/java/ai/blox100/feature_zen_mode/presentation/bottom_sheet_end_session/ZenEndSessionViewModel.kt

Dirty / All: 0.05%

When i uncommented the ksp of compose destinations it shows 100% dirty

Dirty / All: 100.00%

This makes every line change in the code taking 13 seconds extra for building. I have been stuck with this issue for 2 days. Any help would be deeply appreciated.

Simple steps to reproduce

  1. Add these to gradle.properties so that we can see the kspDirtySet.log
    ksp.incremental=true
    ksp.incremental.log=true
  2. run ./gradlew :app:kspDebugKotlin --scan ignore the first build run since this will be 100% dirty
  3. run ./gradlew :app:kspDebugKotlin --scan again this time it will be fully from cache
  4. just add a Log.d("abc", "xyz") line in any of your code and then run ./gradlew :app:kspDebugKotlin --scan again this time again it will be 100% dirty

My main question, is this what it is expected due to the library (or) Am I misisng something?

nizam-betterapp commented 5 days ago

It looks like you have fixed this issue in v2. Is my understanding correct?