Why is Kotlin Native much slower than JVM?

I believe we should agree on what to compare judging if it’s good or bad.
My understanding is there [should be] no fundamental difference in performance of compiled C++ and K/N code, except ARC vs manual memory management. Please correct me if i’m wrong. So i have a feeling that it’s K/N compiler that seems to be the reason [and iperformance was not the goal at the moment]. JB also notes K/N is not ready for performance benchmarking at the moment. Just looking for the opportunity to enable optimizations [which i assume are turned off] to get early rough estimations.

Unboxing works well, performance in pure numerical algoritms is exactly same in “clang -O3”, “konan -opt” and JVM versions, see test:

Not very precise results, but - calculating 1000 digits of PI on my computer:
Clang: 7.0 seconds
Kotlin/Native: 7.0 seconds
Kotlin/JVM: 7.4 seconds

3 Likes

In my experience, the primitives of K/N work quite well but the memory management and the abstractions cost a lot right now, while profiling my K/N websocket server I found that K/N allocate/free very often making the use of abstractions (that use a lot of object) not efficient.