Paddy O'Brien
01/20/2023, 9:09 PM-Xfrontend -debug-time-function-bodies
or support Clang’s -ftime-report
or -ftime-trace
Looking to get granular information on our compile timesPaddy O'Brien
01/20/2023, 9:17 PMdmitriy.novozhilov
01/23/2023, 9:18 AMfun foo() = bar()
fun bar() = baz()
fun baz() = 10
During analysis of function foo
compiler needs to know type of function bar
, which implies that it need to actually analyze bar
. And same goes for bar
and baz
. So to carefully count time we will need to implement logic for distinguish such jumps between functions
• All such measurements won't be accurate anyway (at least at frontend), because analysis of body can invoke number of different heavy calculations, which will be cached after first computation
import java.lang.Thread
fun foo() {
Thread().start()
}
fun bar() {
// 100 lines of code
Thread().start()
}
E.g. in this case real time of analysis of function foo
can be ten times bigger than function bar
(despite the fact that bar
is actually bigger than foo
). The thing is there is a access to class java.lang.Thread
, which came from some .jar
, so when compiler tries to resolve such class it needs to scan all .jar
, find one which contains required class, and deserialize it from .class
file into some representation which compiler is using. And after it was done for some class compiler saves the result and then reuses itPaddy O'Brien
01/24/2023, 7:06 PM