rustc_codegen_cranelift icon indicating copy to clipboard operation
rustc_codegen_cranelift copied to clipboard

Add experimental jit mode integration to cargo

Open bjorn3 opened this issue 5 years ago • 5 comments

https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/jit.20support

bjorn3 avatar Jul 13 '20 19:07 bjorn3

So would this mean:

CG_CLIF_JIT=1 cargo build
target/debug/foo

will:

  1. produce a debug binary
  2. the binary when run, will have instrumentation necessary to jit parts of the code in foo that would normally be AOT

m4b avatar Sep 29 '20 05:09 m4b

No, in the JIT mode the rustc invocation that "builds" the executable actually JITs it and then immediately runs it. No executable is written to the disk. I did imagine that the cargo command would be cargo run --jit.

bjorn3 avatar Sep 29 '20 05:09 bjorn3

Oh interesting, is it possible to share the majority of the dep tree (e.g., i have 400 crates) when jitting, so a modify source, cargo jit loop would be faster?

And today, if i pass this flag to cargo cranelift and do cargo run, this won't do as you say above, right? It only currently works with explicit invocations of the cranelift using rustc, yes?

m4b avatar Sep 29 '20 05:09 m4b

Also, are there any plans to implement 2. I guess it's similar to adding something like a ~~java~~ Rust HotSpot in each binary ; )

m4b avatar Sep 29 '20 06:09 m4b

Oh interesting, is it possible to share the majority of the dep tree (e.g., i have 400 crates) when jitting, so a modify source, cargo jit loop would be faster?

Currently only dylibs can be loaded by the JIT. I want to also make it work with rlibs though.

And today, if i pass this flag to cargo cranelift and do cargo run, this won't do as you say above, right? It only currently works with explicit invocations of the cranelift using rustc, yes?

It will kinda work if you use your cargo build command, but build scripts will also be JITed, causing cargo to fail to run the executable it expects to be created.

Also, are there any plans to implement 2. I guess it's similar to adding something like a java Rust HotSpot in each binary ; )

I may attempt to integrate the Yorick meta tracer in the future. It does require explicit annotations about when to JIT what. It is also only meant to optimize language interpreters, not your average program.

bjorn3 avatar Sep 29 '20 07:09 bjorn3