https://kotlinlang.org logo
#compose
Title
# compose
s

spierce7

10/27/2020, 3:35 PM
Has anyone measured the compilation time of compose? I’m curious because I know compose uses a different version of the Kotlin compiler or something or other. I’m not exactly sure how it works, so I’m curious if there are any problems with it in terms of scaling compose in large projects.
z

Zach Klippenstein (he/him) [MOD]

10/27/2020, 5:59 PM
It uses the stock compiler, but with the new, experimental IR backend (which you can turn on via a flag). It also uses a compiler plugin. The compiler plugin is known to add some lag, since it’s doing more work, but probably not a significant amount. The IR backend should be comparable to the current backend, because it will soon become the default, and it will probably end up getting faster as it’s optimized in the future.
Idk if anyone’s done comprehensive benchmarking
g

gildor

10/27/2020, 11:41 PM
It's also hard to imagine such benchmark, because what would be a baseline?
z

Zach Klippenstein (he/him) [MOD]

10/27/2020, 11:57 PM
I imagine you’d have to build the same complex UI in both classic views and Compose and try to benchmark the compilation? But that code would be so different, there’d be a million variables you couldn’t control for
g

gildor

10/28/2020, 12:31 AM
Yes, this is my point, it would be always comparing apples to oranges I would like to see how much compose compiler adds to compilation in absolute numbers, but it requires someone to build a relatively big application and measure impact of compiler plugin (if it even possible to measure) Also would be interesting to see how incremental compilation works with compose
z

Zach Klippenstein (he/him) [MOD]

10/28/2020, 2:51 AM
@Patrick Yin has done some basic comparisons with (i think) a toy app that uses android views and a similar one in compose, and the compile time only changed a second on a 23-second build time. I’m not sure how many samples he used, but i’m not too worried
s

spierce7

10/28/2020, 4:46 AM
So that was my worry actually. The IR backend isn’t even incremental yet, is it?
g

gildor

10/28/2020, 5:01 AM
I don’t think so. Where did you get this information?
s

spierce7

10/28/2020, 5:06 AM
the IR Compiler is the compiler that’s shared between jvm, js, and native, right? I thought jvm ir compiler was pretty new. I know that native and js (ir) aren’t incremental. I guess I assumed jvm (ir) wasn’t as well.
g

gildor

10/28/2020, 5:08 AM
JS IR is definitely incremental
I think all of them are incremental, including native
JVM IR is new, yes
the IR Compiler is the compiler that’s shared between jvm, js, and native, right
It’s not a compiler, it’s a compiler backend, and yes, part of the code is shared, but because it backend all of them generate own platform code, so it’s not really the same, but more code is reused So about incrementallity we should really talk about compiler in general, not about IR backend, I even not sure that backend
s

spierce7

10/28/2020, 5:36 AM
During the Kotlin 1.4 RC, I asked about slow compilation in the javascript channel, as the IR compiler was noticeably slower than the legacy, and got this response. I didn’t remember it exactly right, but you see where I got the idea from I suppose - https://kotlinlang.slack.com/archives/C0B8L3U69/p1595408441069000?thread_ts=1595361872.066300&cid=C0B8L3U69
g

gildor

10/28/2020, 6:51 AM
it may be not completely ready, but it doesn’t mean that there is no incremental compilation
and compiler IR is not whole compiler