https://kotlinlang.org logo
Title
s

spierce7

10/18/2020, 6:37 PM
So I get that KSP is faster than annotation processors, but how much overhead do they add? They are incremental right?
w

wasyl

10/18/2020, 6:44 PM
Here’s one data point, Square’s Anvil can generate some Dagger factories, removing the need to run kapt. Overall the build is faster, but the overhead on kotlinc is pretty big though https://github.com/square/anvil#experimental-dagger-factory-generation
s

spierce7

10/18/2020, 6:57 PM
This is exactly the kind of thing I was looking for. Thanks!
Overall the build is faster
Isn’t it 4% slower? Faster thank kapt you mean?
the overhead on kotlinc is pretty big though
Where are you getting that from out of curiosity?
w

wasyl

10/18/2020, 7:02 PM
Yes, faster than kapt:
In our codebase we measured that modules using Dagger build 65% faster with this new Anvil feature compared to using the Dagger annotation processor:
And later on
For full builds of applications we measured savings of 16% on average.
The Kotlinc overhead I’m getting from the table, where with regular Dagger, kotlinc took 10s while with Anvil/KSP it takes almost 18 seconds. That’s not strictly KSP overhead though, as some logic has moved from Dagger to KSP (and is now executed in kotlinc) so this 8 additional seconds is some real work that needs to be done too
j

Jacob Applin

10/19/2020, 2:53 PM
@wasyl were you able to remove the dagger annotation processor entirely from the module? How does anvil enable that?
w

wasyl

10/19/2020, 4:02 PM
@Jacob Applin I didn’t try Anvil yet. But from what I understand this experimental feature doesn’t replace Dagger completely. Instead, you can use Anvil instead of Dagger in those modules that don’t declare components, just have
@Inject
and
@Provides
annotations
j

Jacob Applin

10/19/2020, 4:04 PM
nice I didn't know they'd added this feature I'll have to give it a try
j

Jiaxiang

10/20/2020, 2:37 AM
Incremental is WIP, overhead is dependent on the processor itself, like how many symbols and types are being resolved for processing.