https://kotlinlang.org logo
Title
m

msink

08/11/2017, 11:28 PM
For now Kotlin/Native generates order of magnitude bigger and slower code compared to plain C equivalent.
n

napperley

08/11/2017, 11:40 PM
How much bigger (code, runtime and standard lib size) is Kotlin Native than C? Very important to have some basic Kotlin Native CLI profiling tools to measure performance in a number of different areas. Some of the areas covered by the profiling tools would include code size (as mentioned ☝️), memory (RAM) consumption separated by stack/heap and element type (classes, objects, variables, constants etc), CPU usage, number of times the Kotlin Native program blocks and how long each block occurs (concurrency).
m

msink

08/11/2017, 11:42 PM
Last time I measured - it was approx 20x times bigger.
Not counting stdlib, just code generated by compiler.
o

olonho

08/16/2017, 4:13 PM
I am not sure if this statement is correct, so would suggest people to perform their own measurements
m

msink

08/17/2017, 12:40 PM
Ok, fresh measurement: https://github.com/msink/kotlin-blink Result: 11.3 times bigger.
n

nish

08/17/2017, 1:59 PM
Does Konan do any dead code elimination?
n

napperley

08/17/2017, 10:00 PM
Does the upcoming Kotlin Native benchmark tools cover code size?
Real need to have a basic Kotlin Native sample which is suitable as a reference point for benchmarks (incl code size).
m

msink

08/17/2017, 11:09 PM
That "blink led" sample is quite real - it's like "hello world" for microcontrollers.
n

napperley

08/18/2017, 12:23 AM
What is the target hw (is it targeting the Rpi)? Does the Kotlin code size include the Kotlin Native runtime and std lib?
m

msink

08/18/2017, 3:59 AM
No, I compiled it on windows host for windows target, x86-64. For another targets both sizes will change, so difference will be the same, more or less. And no, I do not count stdlib, so difference really is even worse.
o

olonho

08/18/2017, 12:06 PM
guess this kind of measurement is close to useless, when comparing text segment for trivial C and Kotlin programs, probably bigger size application having data structures and computations shall be compared
m

msink

08/18/2017, 12:11 PM
what data structures? it counts only size of "main" (89 bytes) and "Konan_start" (1004 bytes).
o

olonho

08/18/2017, 12:59 PM
usually maps, list, sets are considered data structures
m

msink

08/18/2017, 1:11 PM
did you see that repository? disassemled listings of relevant procedures do not include any of this maps, sets etc.
o

olonho

08/18/2017, 1:22 PM
sure, but the point is, that to meaningfully compare size of programs, they have to do something valuable, for example manipulate with some data structures
m

msink

08/18/2017, 2:18 PM
microcontrollers do not manipulate that structures, it manipulate io ports.
Question was "is K/N usable in Ucs?" - answer is "no, for now". In many other use cases answer is different, of course.
n

napperley

08/19/2017, 3:22 AM
Isn't a language unusable without a standard lib (covers all basic data types, basic debugging via print..., basic collection functionality etc)?
There are other languages like Python (via Micro Python) which have been successfully ported to uCs (

https://www.youtube.com/watch?v=zYAUl1lqapU

). Kotlin SHOULD be portable to some ARM based uCs with the right changes under the hood in due time... 🕐 . Put it this way since JS can run on some uCs 😲 (

https://www.youtube.com/watch?v=j1TsCmDhFtk

) 🏃 it is possible to write some embedded programs using a high level language, which will run on some uCs.
My point about the need for Kotlin Native profiling tools still stands, and has been validated with some of the previous messages. Currently there is no easy/accurate way to determine resource usage of a Kotlin Native program (eg CPU usage, RAM used, code size). It is like navigating a room in the dark 🕶️ (inaccurate), which when translated to Kotlin Native development isn't a good way to determine if a Kotlin Native program is using too many resources or not (guessing doesn't work well).