chc4 / lineiform

A meta-JIT library for Rust interpreters
156 stars 4 forks source link

Better tracing #18

Open chc4 opened 2 years ago

chc4 commented 2 years ago

Right now we just println a bunch, which sucks.

nbp commented 2 years ago

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.

chc4 commented 2 years ago

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.