google / ksp

Kotlin Symbol Processing API
https://github.com/google/ksp
Apache License 2.0
2.81k stars 264 forks source link

Areas for possible performance improvements #808

Open yigit opened 2 years ago

yigit commented 2 years ago

I've been running some profiling with KSP and Room.

This is a tracking issue to log some findings. I'll try to turn some of these findings into PRs but I thought it would be good to share some findings here.

When I profile Room we spend significant time in resolveType, which does in fact make sense.

There a couple options to improve performance there:

I'll try to keep this issue updated as I have time to do further measurements. Just wanted to get this log started.

yigit commented 2 years ago

So I've implemented relatively better measurements in room. The changes in that CL can improve resolveUserType performance by 20% (and force resolve performance by 80%) but all things considered, it only comes to a 3-4% overall improvement in room (better than nothing but not super effective either).

There is still some unaccounted time for which I need to add more metrics around to better understand this.

I also noticed that the difference is more significant when daemon is not used, which is what i was using to attach the profiler but should stop doing that (e.g. resolveUserType gets 30% faster with fresh compiler vs only 20% faster with a daemon).