4 ms·
> Rust borrow checking is quick, as shown by cargo check. Looks like monomorphization part is not caught during cargo check according to https://github.com/rus
by menaerus 4y ago
> Rust borrow checking is quick, as shown by cargo check.
Looks like monomorphization part is not caught during cargo check according to https://github.com/rust-lang/rust/issues/49292 https://github.com/rust-lang/rust/issues/49292
Reporter of the bug says:
> All of those happens somewhere inside librustc_mir, most of them being monomorphization. This corresponds to translation item collection pass, which takes nontrivial amount of time.
Which essentially means that cargo check is not doing all the checks that cargo build will do, so the comparison seems to be a bit off, at least for the time being. And consequently this inconsistency can easily lead to the hypothesis of LLVM backend being the bottleneck.
I guess the only reasonable way to know for sure where are the biggest bottlenecks in build times is to have something similar to clang's -ftime-trace but I couldn't find anything similar existing in Rust.
From what I understand, monomorphization and rust macros are essentially C++ templates in a nutshell, and probably less than, yet C++ is compiled much faster. Given that both clang and rust share the same LLVM backend, this seems like an indication to me that the bottleneck is rather in the frontend and not in the backend. It also could be that Rust frontend pipeline is not quite optimized yet so that it puts more pressure to LLVM backend than what the clang does but seems like we can't really know that for sure.