-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KSP: Performance regression after migration to KSP #9750
Comments
How big is your project? |
Thanks for looking into this. We have roughly 3k classes and interfaces in our project |
We have the same experience with a small project. |
I have merged an improvement, you can try 4.0 SNAPSHOT or wait for next 4.0.X release |
Can you please try the 4.1 platform? |
Our project doesn't really build with KSP yet. Our next blocker is #9764 |
I think I can come up with more improvements. Not sure what to do about the open issue… we might need to provide our own set of open annotations. |
@dstepanov unfortunately, without some workaround for that issue it's not feasible for us to get a full build on ksp. We have to explicitly open all our Singletons that perform any validation on the parameters. I offered a solution there by letting users modify |
Can you somehow share the profiling info? |
@dstepanov Here is the exported VisualVM CPU sampling snapshot. Let me know if you need async-profiler results or anything else. |
We've avoided some of these regressions for now by switching back temporarily to kapt. We are all in on KSP but we've hidden our use of ksp behind a flag for now so we can test without disrupting build times. Kapt is still supported on Micronaut 4. We hadn't realized that initially so I wanted to share here in case that's useful for any other V4 adopters. |
One other note: in our experience, clean build times are longer but cached build times with KSP are much faster than the equivalent with kapt. Over time it seems like KSP will win on both a performance and functionality basis. So that's why we went with a flag. |
#9832 made a big difference cutting down the build time until the allopen + ksp failure that our project experiences in half |
On a project kaptKotlin takes 14 seconds with the current 4.3.0-SNAPSHOT. kspKotlin takes 40 minutes to run into "Method defines AOP advice but is declared final. Change the method to be non-final in order for AOP advice to be applied." on 4.3.0-SNAPSHOT. Partial CPU samplings of the kspKotlin steps: Kotlin 1.9.20 and ksp 1.9.20-1.0.14: Kotlin 1.9.22 and ksp 1.9.22-1.0.16: |
probably the PR that resolves annotations on generic arguments via inheritance causes this //cc @dstepanov |
I'm also a little puzzled to see |
I suspect that caching might not work for KSP, might be a good idea to recompile the project with some added printl and check |
@Spikhalskiy Please try with the latest snapshot |
@dstepanov It's much better than before. kspKotlin takes about 1m30 seconds now before failing. Still significantly longer than kapt, but much better than 4.1.x 4.2.x performances. Thank you! |
@Spikhalskiy Still, it takes a lot of time. Maybe you need to add more memory for Gradle? Our
|
@dstepanov Our timings are: kaptKotlin (without generating stubs, it's a separate task): 15s We already give kotlin daemon 4Gb, I tried to increase it to 8Gb and didn't see much of a change in timings. I inspected the kotlin daemon with Visual VM and didn't see significant GC pressure. |
When the KSP is enabled there is no KAPT task right? |
You should have just those two tasks like the message above |
Yeah, it's mutually exclusive. I just put them together for comparison. It's either-or.
correct |
Is that still the override method check that takes much time? |
Kinda. |
Hard to tell, but findOverridenMethods should be called once per class |
Similar thing happened in one of my bigger projects where kapt worked but ksp failed with a "GC overhead limit exceeded" exception or it took just too much time complete. I got ksp to work by adding compileOnly("io.micronaut:micronaut-inject-kotlin") to my gradle build file. |
We would need a project that reproduces the performance regression to improve performance. |
Expected Behavior
After migrating from kapt to KSP, we notice a large performance regression:
Both
kaptGenerateStubs
andkaptKotlin
combined take ~1.5 min on my machine.kspKotlin
takes over 30 mins, at which point I aborted the task.Actual Behaviour
I expected the
kspKotlin
step taking significantly less time thankaptGenerateStubs
andkaptKotlin
combined.Steps To Reproduce
Unfortunately I don't know what exactly in our codebase triggers this issue. If there are anything more that I can provide apart from the attached VisualVM sampling profile, I'm happy to help.
micronaut-ksp-perf-issue.nps.zip
Environment Information
Example Application
No response
Version
4.0.4
The text was updated successfully, but these errors were encountered: