lineiform icon indicating copy to clipboard operation
lineiform copied to clipboard

Better tracing

Open chc4 opened this issue 4 years ago • 2 comments

Right now we just println a bunch, which sucks.

  • [ ] Switch to tracing so we have introspection into how long specific parts of the program are taking
  • [ ] Save cranelift_codegen::cfg_printer::CFGPrinter to disk so we can visualize the JIT'd program CFG better (and maybe build our own graphviz printout for JitValues?)

chc4 avatar Sep 13 '21 04:09 chc4

Intel CPUs have a feature which allow recording the traces of taken branches in the form of a record with a from & to pointer. Look for "branch trace" in the intel documentation.

I never used it, but this could potentially be used to record traces of execution of any code, even the one generated by the Rust compiler. Thus removing the need for instrumenting the code to recompile it later.

nbp avatar Feb 17 '22 11:02 nbp

The tracing in this issue is actually about switching to use the tracing crate for diagnostics, not collecting JIT traces :)

Intel BTS and PT are both very cool technologies, and would be a good fit if we needed to. Currently Lineiform is designed as a method based JIT, not a tracing JIT, so we never record execution traces, only inline and constant fold closed environment members in the closure inputs. There are some tradeoffs between method and tracing JIT, where tracing is really good at optimizing hot loops and deep call stacks, but I don't think there is a consensus on which is definitively better, so I'm just going to stick to method-based for now.

There is another meta-JIT project I know of (https://github.com/ykjit/yk) that is planning on using Intel PT to collect JIT traces, and I'm curious to see how it turns out.

chc4 avatar Feb 17 '22 13:02 chc4