I'm actually curious how ksp's separate task runs ...
# ksp
z
I'm actually curious how ksp's separate task runs without the same overhead as the normal
compileKotlin
task. I imagine it maybe runs the frontend only (i.e. not the backend?), but I thought the frontend was also where the bulk of the slowdown was and being replaced with
fir
. On paper it seems like this is effectively running compilation twice like kapt does in its task, which presumable would work via similar mechanism
t
ksp calls kotlinc's front-end on demand. It tries to call the compiler as minimum as possible. For example, if a processor is only interested in knowing the declaration of the return type of a function, only this reference to the return type is resolved in the compiler. In contrast, every type references at interface / function signature level are resolved in kapt, in order to generate java stubs. The optimal case for ksp is a processor that does not resolve any references. The cost of compiler is roughly parsing the sources, which is pretty fast compared to analysis / resolution. The worst case for ksp is a processor that tries to resolve everything. In that case ksp should be on par with kapt. All processors are somewhere between those two extremes, and we believe most are closer to the first.
z
interesting, thanks