Support vtune profiling of trampolines too - #3687
Conversation
Subscribe to Label Actioncc @peterhuene DetailsThis issue or pull request has been labeled: "wasmtime:api"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
alexcrichton
left a comment
There was a problem hiding this comment.
Looks great to me, thanks!
| /// Unique identifier for the jitted function | ||
| method_id: HashMap<(usize, DefinedFuncIndex), u32>, | ||
| /// Unique identifier for the jitted code region. | ||
| method_id: HashMap<MethodKind, u32>, |
There was a problem hiding this comment.
Reading over this now, there's actually a fair bit supporting this map right here, but this map is only used for an assert that each item inserted is unique. I think that may mean perhaps that we could remove this entirely? (and not worry about MethodKind as a new enum)
There was a problem hiding this comment.
Indeed, the module id we feed ourselves and the signature index will always be different anyways, so this sanity check isn't worth the trouble.
Kept the mutex, though, because I'm unclear whether the ittapi function can be called from several threads at the same time 🤔
|
Oh sorry and to clarify, you're right that The |
|
Updated! Also refactored a bit how the loading of dynamic trampolines is done, so that there's less code duplication with the jitdump_linux; if that approach looks good to you too, I could go ahead and do the same for single functions and trampolines for exported signatures? |
cbfebcf to
1d77b37
Compare
|
Looks great to me, thanks! Did you want to do that refactoring as a follow-up or attach here? (either way is fine by me) |
Can do that here! I wanted to make sure this is something we wanted first 👍 |
|
Ended up giving up on the refactoring (instead of loading a whole module at once, load function per function), because:
Anyhow, this added more lines of code than there was before, and made the code messier overall, so not a win in my opinion. Spotted a data structure that could be removed, though! |
|
Seems reasonable to me! |
This refactors the code as suggested to avoid duplication of demangling (and allows having a single crate depend on the demangling crate dependencies). Also implements supports for trampolines in vtune.
After poking at the code, my understanding was that
module.trampolines()contained metadata about trampolines for exported wasm functions, whiletrampoline_load()would be called for trampolines into and out of imported wasm functions. Is that true @alexcrichton? Weirdly enough, even by adding some println statements to check if those trampolines were generated, I could only see the printed messages formodule.trampolines(), not for the other one. Am I missing something in there?