Why is rust compilation faster than Julia pre-compilation?

Definitely not replace :slight_smile:

There was some brainstorming about a cranelift backend for Julia a while back, but it hasn’t gone anywhere: Cranelift: a faster alternative to LLVM. It would be really cool to see, cranelift is mature enough nowadays that you don’t hit many bugs using it with rustc (missing features yes, but not things like wrong codegen) and it really does have noticeably faster compilation times. I recommend trying it with the evcxr

For what it is worth, the project that provides Rust’s Jupyter kernel also provides a REPL for Rust GitHub - evcxr/evcxr. Would be interesting to see a benchmark between the two.

—-

Currently rustc does not parallelize the frontend. The backend is parallelized by splitting a single crate into as many orthogonal codegen units as possible before handing it to LLVM (codegen-units compiler flag, default maximum is 255), which can then build in parallel. These individual codegen units can then be reused or recompiled as needed to support incremental compilation. There is work to parallelize the frontend too, currently available on nightly, which will add another nice speed boost when it becomes stable. Crates compile in parallel where allowed by the dependency graph.

I don’t know much about the Julia side here but I have to imagine it isn’t splitting codegen units as optimally as it could be, which is tougher to do with the interpreted model. Same for frontend parallelization, I’m not entirely sure how that would work.

Rust does pretty well with the infra side of things too. As @Zentrik mentioned above, a performance suite gets run on every single commit (perfbot has dedicated machines, a run takes about 2 hours) and it is easy to run it on an individual pull to see the deltas (search the PRs for @rust-timer queue). So the barrier to entry is pretty low for somebody wanting to make performance contributions, which helps get interest - a few % wins here or there really add up. Julia may have something similar, I just have no idea.

Julia has been doing a great job getting startup times down in the past couple years, it will be exciting to see how good it gets.

8 Likes