-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jitdump support sometimes doesn't work #2018
Comments
@alexcrichton Sorry for taking so long to chime in. Yes you're right, the only difference does look like how the func is created. I have not run jitdump with an embedded instantiation in this way but will try to trace to see what is going wrong. If the difference between wrap and new is really just when the trampoline is created then I guess they should have no bearing. Also not sure the impact of #1565 but will investigate. |
Oh no worries! What I gisted above was basically a reduction of the CLI to a smaller thing to poke around with. I did some investigation over the weekend, though, and I don't think that this is our bug. I believe that this behavior is a "feature" of I managed to reduce this code even more to something that was pretty bizarre. That gist sort of simulates what we're doing in Digging into The problem is that this extra "mmap2" event claims that it spans the entire area of JIT code we just emitted. So what I did my best to figure out why perf thinks there's an mmap2 event for such a large region of the address space when clearly First, just after the call to
After the
which I think starts to explain things. It just so happens that our trampoline JIT memory sits just before the rest of the module's JIT memory, so that when we map them all as the same permissions the The tl;dr; I think is basically:
Overall there's no bug in Wasmtime from what I understand. I'm not even sure if this is a bug in |
@alexcrichton excellent. Hi Alex, very good analysis. What you describes sounds like a good explanation and I would like to go through your steps and see for myself if I can duplicate your findings. Also, maybe off base but I am wondering about the other record, JIT_CODE_MOVE, and whether it may be of help here? Specifically, if we describe the trampoline and jitted code with the JIT_CODE_LOAD record (are we including the trampoline properly??) then should we be using JIT_CODE_MOVE when the mprotect call happens. |
This has since been fixed not because I think we did anything but because the layout of jit code is different to prevent the adjacent regions as described above I think there's probably nothing we can do about this otherwise and as long as we stay our current course in the representation of jit compiler outputs I think we'll be ok. |
I noticed recently that jitdump support seems broken on master when used through the wasmtime CLI. I'm pretty perplexed by this, especially because bisection pointed to #1565 as a cause. I think, though, that #1565 as a cause is a red herring, and this has always been a bug. Given this
fib.rs
:along with this embedding:
When this is run as:
this will not attribute time to
fib::fib
, but instead lots of jit addresses show up:If, however, the line with
//changeme
is switched totrue
then you'll get the profile as expected:I'm honestly not entirely sure what's going on. I don't think that our jitdump integration is what's broken. The
*.dump
file emitted looks reasonable,perf inject
appears to work,*.so
files pop up and they've all got functions in them with names as expected. I'm not really sure what's happening here.@jlb6740 do you know more about
perf
perhaps to help debug? It'd be great to know whyperf
is failing to recognize the function in one case but not the other.The only real difference here seems to be what's on the stack, whether it's native versions of trampolines (
Func::wrap
) or runtime-generated versions of trampolines (Func::new
). We don't tell jitdump about the trampolines generated byFunc::new
but after doing that it didn't seem to fix anything. Additionally I think we have unwind info for everything registered, but I'm not even sure why perf would want to unwind since we're not collecting stacks, just samples.Overall I'm at a loss myself and I'm not sure what to do next. I'm hoping @jlb6740 you've got ideas of what might be going on :(
The text was updated successfully, but these errors were encountered: