What part of Rust compilation is the bottleneck?
kobzol.github.io
kobzol.github.io
For every generic function f, rustc will generate as many instances as there are type instances (shape instances? Does the Compiler distinguish between different kinds of references that all get compiled to pointers?).
This feature has a cost. Compare to OCaml's uniform object representation that enables comparatively blazing compilation performance but pays a prize in performance and weird FFI restrictions (integers with a tag bit).
Btw. It's misleading to say "it's the backend" when the frontend is responsible for creating so much work for it.
That's the most important point I think. Clang compiling typical C code is very fast, but the same Clang compiling typical C++ code is very slow. Both use the same LLVM backend.
By using binary libraries, external templates for common type sets, incremental compilation and linking, and nowadays (at least for VC++ already) modules.
What Rust still lacks is having sound alternatives to LLVM, or someone supporting similar workflows in Rust.
Using OCaml as an example, it is great to have multiple backends in the box, plus an interpreter, and pick and choose during development workflows.
Imagine the safety of Rust but looking more like Python (or Haskell...), the concurrency of Go (since V5), and without a borrow checker (but a GC instead).
These are my very subjective hobby benchmarks running archlinux on an AMD 9 7940HS.
Of course the initial build or the release build take much longer, but it makes me hopeful for the future.
My theory is that because Rust is a low level language you tend to miss out on higher level primitives that promote more code reuse. Another theory is that Rust is mature but not quite as mature as something like Java, so there are fewer mature dependencies for you to delegate your work to.
Thoughts on what’s accurate? For context, I’ve written a bit of Rust myself, but am definitely a beginner.
Generics and cross-crate inlining enable zero-(runtime)cost abstractions, meaning there’s usually no perf downside to using 3rd party code instead of your own.
Strict type system, standardized error checking, thread safety in interfaces, and built in tooling for API documentation makes using libraries relatively easy.
The ecosystem is pretty large now, and has a culture of respecting semver, and focus on safety and reliability.
Cargo makes adding dependencies easy (the most common complaint is that it’s too easy, and people use too many dependencies).
Go support on Windows is also not great, plugin package doesn't work, filesystem support assumes POSIX semantics, cgo requires installing mingw.
Wait, there is an LLVM based Go toolchain? I thought the Go crowd was known for their NIH obsession.
My love for types peaked when I was in my mid-40s, now that I'm 50+ I want simple things.
http://lambda-the-ultimate.org/node/4554#comment-71504
At least it does generics now.
Not in gccgo
TinyGo also doesn't do them.
Of course it is good to be reasonable - some people completely fly off into the FP world and instead of actually building working stuff they think all day about some clever abstraction and types to model it.
The Go compiler being written from scratch based on the Plan9 C compiler is a huge advantage.
I want fast compilation for my dev cycle or for unit tests, I want slow compilation with optimizations, escape analysis, correctness etc. for production (the distinction between a compiler and linter is also not clear, some compiles do what linters do in other languages).
You can get pretty big differences in terms of compile speed / binary size
Increasing Codegen units (multi unit compilation) is just the user taking a risk that splitting things up will not affect performance optimisations. Nothing smart about it.
If you had tiny compilation units and the frontend understood their significance to the backend then it would be able to build a graph of dirty code to be recompiled when a small piece of it changes.
Disclaimer: I concur that this is merely a workaround, not the real fix
If we can squeeze more performance that's great but the largest concern I have around compilation is with the size of the target directory
It can balloon up to node_modules levels