Hello, guys, I am wondering what are the practica...
# ksp
g
Hello, guys, I am wondering what are the practical differences of incremental processing to processors, and if I need to make anything specific to assure that a processor I created is incremental. After reading some documentation regarding KAPT, It seems to me that as long as the only code that change is internal code inside methods, symbol processing will not kick in. But as soon as there’s some other kind of change, the entire processing will be done from square one. I was wondering if that’s the case, or if it would mean symbol processing would only process symbols that changed (i.e.: new/modified annotated classes), while caching symbols that have been previously successfully processed, and passing the cached data down to processors along with what’s new.
t
It's something in the middle (of only reprocessing changed symbols v.s. everything). Symbols that can be "affected" by the changed symbols also need to be reprocessed. Both KAPT and KSP tries to reprocess as fewer symbols as possible. One important difference is that KSP tracks dependencies dynamically while KAPT delegates processing to javac and needs to be conservative; For example, if symbol A is changed, then every other symbols that are reachable from A must be reprocessed in KAPT. That's why someone may observe that a tiny change triggers everything. In KSP, only those symbols that were actually navigated (from or through A) by the processor need to be reprocessed. Although the worst case is the same, it should be much better on average. Another thing to consider is that, it's very common for a project to apply multiple processors at a time. If there is one non-incremental processor, it will pull the entire source set to be reprocessed and effectively makes every other processors non-incremental.
g
So, what my processor currently does is it aggregates classes annotated with an specific annotation in a large map. That was my initial ideia to get that working before trying to be more efficient. Since it’s all in one file, if the processor gets triggered for only a single new annotation, the file is currently being erased and rewritten solely with it’s inputs. I think my processor probably isn’t incremental then. I’ll try to come up with something, but it’s kind of tricky since I want everything to be eventually centralized and lazily evaluated. Maybe I’ll have to let lazy evaluation go. Dagger+Anvil should bring ideas.