-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Optimize Kotlin reflection runtime efficiency #21546
Comments
Short term |
Kotlin Coroutines are now supported but require additional reflection entries due to how Coroutines generates bytecode with an `Object` return type, see spring-projects/spring-framework#21546 for a potential future fix. Closes gh-409
After a deeper look, I am not sure So my hope for the future is that we could collaborate with Kotlin team (cc @udalov @elizarov) to have a more optimized version of Could be useful for Jackson Kotlin support as well. That would be a good fit with Spring Framework 6. |
See also this related comment Kotlin/kotlinx.reflect.lite#12 (comment) and this one on KT-11386. |
This commit migrates Spring Framework from using the "full" Kotlin reflection API to the "light" reflection API. Closes spring-projectsgh-21546
@sdeleuze Yeah I do not think Jackson 2.16 will be ready by July. |
Ok, I moved this issue to the 6.x backlog, that will let the time to Jackson to evolve to support the new Kotlin reflection, then we will re-evaluate this after Spring Framewor 6.1. |
After more thoughts, I begin to be increasingly convinced that if we do something here, I think that should be with Would somebody from the community have the bandwidth and be interested to help moving that topic forward by replacing Those information would be useful feedback for Kotlin team to make |
I would like to work on this issue. |
Great, I will let this issue open then, and wait for your feedback. |
I have checked on Personally, I find it more practical to use |
Let me check with the Kotlin team. |
After discussing with the Kotlin team, it looks like to path to move forward it to use @k163377 If you want to work on such branch, I could then run my benchmarks on it to share data points and see how much we gain in term of efficiency (CPU and memory overhead). |
Do By the way, I would appreciate it if you could vote for the following ticket to improve the performance of metadata readout. |
I think the answer is no as
Wondering the same especially given the recent improvement in Spring Framework
I will but be aware that |
See related interesting comment here. |
As discussed in #33026, ideally fixing that issue would allow to:
|
I have done new measurements with The allocation flamegraph still shows a huge flame for I have then measured startup time and memory consumption for a simple Spring Boot webapp with 3 variants: Java, Kotlin with Java 0.811 seconds (process running for 0.98) 191 MB RSS Kotlin with 0.951 seconds (process running for 1.132) 233 MB RSS Kotlin with 0.836 seconds (process running for 1.008) 190 MB RSS I will discuss with the Kotlin team to see if/how we can move forward. |
kotlin-reflect
is a big 2 MB JAR, producing important CPU and memory spikes at startup on the JVM.It would be interesting to explore if it could be replaced by a lighter incarnation like https://github.com/Kotlin/kotlinx.reflect.lite or use
kotlinx-metadata-jvm
at build time to generate some kind of reflection index.jackson-module-kotlin
should also work with similar approach (not blocking now that we have Kotlin Serialization support).The text was updated successfully, but these errors were encountered: