question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Anvil 2x slower than Dagger

See original GitHub issue

I recently added Anvil to a project, that had both Dagger and dagger-android (sigh), and I noticed 2x-3x clean/incremental build times .

I managed to repro it in a sample project. First commit of that PR uses Anvil, second commit uses Dagger to contribute a module to the AppComponent. Running gradlew --scan buildDegug for clean and incremental builds, in both commits yields the following:

with Anvil (1st commit)

with Dagger (second commit)

For the incremental builds, it seems that app:compileDebugKotlin is not incremental when using Anvil, I was not able to figure out why.

Note: To trigger incremental builds I just added a timber line into the Dummy#dummy method

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:10

github_iconTop GitHub Comments

1reaction
vRallevcommented, Jan 6, 2021

I don’t have any other recommendations. Like I said we only enable the Dagger annotation processor and Kapt in the final app module. Everywhere else we rely on Anvil to generate Dagger factories. We don’t use any other annotation processors. Because of that we saw a significant improvement in performance.

1reaction
aitorvscommented, Jan 1, 2021

@vRallev thanks a lot. I have fixed the access to the sample project now.

I have run with :app:assembleDebug --info and it seems the task :app:compileDebugKotlin is incremental

Task ':app:compileDebugKotlin' is not up-to-date because:
  Input property 'classpath' file /Users/aitor/code/android-scaffolding/dummy/build/intermediates/compile_library_classes_jar/debug/classes.jar has changed.
Anvil: Incremental compilation enabled: true (compile)
Anvil: Use precise java tracking: false

However, when using anvil it takes a lot more time.

With dagger

Task ':app:compileDebugKotlin' is not up-to-date because:
  Input property 'classpath' file /Users/aitor/code/android-scaffolding/dummy/build/intermediates/compile_library_classes_jar/debug/classes.jar has changed.
Anvil: Incremental compilation enabled: true (compile)
Anvil: Use precise java tracking: false
...
...
:app:compileDebugKotlin (Thread[Execution worker for ':',5,main]) completed. Took 0.055 secs.

with anvil

Task ':app:compileDebugKotlin' is not up-to-date because:
  Input property 'classpath' file /Users/aitor/code/android-scaffolding/dummy/build/intermediates/compile_library_classes_jar/debug/classes.jar has changed.
Anvil: Incremental compilation enabled: true (compile)
Anvil: Use precise java tracking: false
...
...
:app:compileDebugKotlin (Thread[Execution worker for ':' Thread 11,5,main]) completed. Took 0.787 secs.

Could you shed some light as to why this happens?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending Anvil for Fun and Profit - Slack Engineering
Extending Anvil to enable new Dagger dependency injection patterns in our codebase. ... It slows down our builds with kapt, has a steep...
Read more >
Crafting; All You Need to Know - Ashley and Micah English
Anvil + Any Knife = Dagger Anvil + Large Iron Bar = Two-Handed Sword ... You will need a pair of "immune to...
Read more >
Crafting | Divinity: Original Sin - OldGames.sk
Category Input #1 Input #2 Output Skill armor Anvil Cloth Scraps Homemade Cloth Boots Crafting 1 armor Anvil Leather Scraps Homemade Leather Boots Crafting 2 armor...
Read more >
Statblocks & Sheets | World Anvil
Shortbow + 20 arrows ('well... shit. It'll do until I can get a firearm. I guess.') Thieve's tools ('time to force entry') 2x...
Read more >
ivar_recipes.pdf - Divinity - Original Sin
[C2]: Slow Current, Ice Shard, Summon Ice Elemental, Rain, Minor Heal, Slow, ... Use it to kill Shambling Oaks. Spear. = Branch. +....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found