fn main() {
println!("Hello, world");
}
Take this simple program and modify it by adding more consecutive println!("Hello world"); lines. Compile it with -Z time-passes and observe how long typechecking takes. I've compiled a table below.
Calls to println! |
Typechecking time (seconds) |
| 1 |
0.001 |
| 2 |
0.001 |
| 4 |
0.003 |
| 8 |
0.003 |
| 16 |
0.007 |
| 32 |
0.014 |
| 64 |
0.048 |
| 128 |
0.119 |
| 256 |
0.386 |
| 512 |
1.316 |
| 1024 |
4.893 |
| 2048 |
19.227 |
| 4096 |
82.713 |
| 8192 |
Sits at typechecking for minutes, then fails with "Illegal instruction" |
Here's the full output of time-passes for the 4096 case, to see the enormous disparity between typechecking and the other passes (though liveness is another offender):
time: 0.022 s parsing
time: 0.002 s gated feature checking
time: 0.000 s crate injection
time: 0.003 s configuration 1
time: 0.003 s plugin loading
time: 0.000 s plugin registration
time: 0.474 s expansion
time: 0.036 s configuration 2
time: 0.036 s maybe building test harness
time: 0.032 s prelude injection
time: 0.005 s checking that all macro invocations are gone
time: 0.045 s assigning node ids and indexing ast
time: 0.005 s external crate/lib resolution
time: 0.008 s language item collection
time: 0.120 s resolution
time: 0.009 s lifetime resolution
time: 0.006 s looking for entry point
time: 0.004 s looking for plugin registrar
time: 0.030 s region resolution
time: 0.004 s loop checking
time: 0.004 s stability index
time: 0.004 s static item recursion checking
time: 0.024 s type collecting
time: 0.009 s variance inference
time: 0.080 s coherence checking
time: 82.713 s type checking
time: 0.057 s check static items
time: 0.065 s const marking
time: 0.005 s const checking
time: 0.025 s privacy checking
time: 0.020 s intrinsic checking
time: 0.015 s effect checking
time: 0.226 s match checking
time: 55.143 s liveness checking
time: 2.312 s borrow checking
time: 0.104 s rvalue checking
time: 0.002 s reachability checking
time: 0.115 s death checking
time: 0.190 s lint checking
time: 0.001 s resolving dependency formats
time: 1.998 s translation
time: 0.108 s llvm function passes
time: 0.025 s llvm module passes
time: 0.902 s codegen passes
time: 0.002 s codegen passes
time: 1.179 s LLVM passes
time: 0.359 s running linker
time: 0.363 s linking
This seems to contradict our usual excuse for compiler slowness of "it's not our fault, it's LLVM".
Take this simple program and modify it by adding more consecutive
println!("Hello world");lines. Compile it with-Z time-passesand observe how long typechecking takes. I've compiled a table below.println!Here's the full output of
time-passesfor the 4096 case, to see the enormous disparity between typechecking and the other passes (though liveness is another offender):This seems to contradict our usual excuse for compiler slowness of "it's not our fault, it's LLVM".