-
Notifications
You must be signed in to change notification settings - Fork 5
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
[Plat 9771] Add wasm-opt pass to instrument functions #6
[Plat 9771] Add wasm-opt pass to instrument functions #6
Conversation
* Enable loading of config from command line * Add option to embed labels into data section or as json file * Add option to configure path to label.json file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR, Marcel! Just a minor thing, can you please add the link to PLAT-9771 (it's just easier than look for it in Jira)?
I'm not too familiar with this repository bur I think the performed testing adds enough coverage for the changes.
The only question I have is how do these changes affect the rest of the code? How confident are you that nothing else needs to be tested/sanity checked for possible regressions?
I am pretty confident that the change does not have an effect on other parts of the code. The passes work independent from each other so if the pass is not used in the command line the code is never run. The existing test suite also runs the other passes so I am confident that my change did not break anything else. |
49d15fd
to
2dcb034
Compare
2dcb034
to
f5d7458
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Marcel. In this case no additional testing is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too familiar with the codebase but seems straightforward and solid 👍
(not that it matters, but you example commands have |
Purpose of this PR
This PR adds a pass to wasm-opt to add a configurable logging call to functions. This allows to profile which functions were called.
The log function will receive the id of the function(ordinal inside WASM file) and a label id. The label id is either an offset into the the global memory that allows to read a C-String or can be used to look up the label inside a external .json file.
A config file allows to define which functions should be instrumented and what label is assigned to which function.
Usage:
Example
instrument-config.txt
:JIRA Ticket: PLAT-9771 Implement pass in binaryen that instruments an existing WASM file to profile used/unused submodules
Definition of Done
Testing
Manual testing done by running the tool as shown above.
Automated testing added to the binaryen test suite.
test/passes/instrument-functions=a;Submodule 1;b;Submodule 1;c;Submodule 1;d;Submodule 1;e;Submodule 1;f;Submodule 2;h;Submodule 3_pass-arg=instrument-functions-labels-in-data_enable-simd.txt
Run binaryen tests locally with with:
# with compiled binaryen in ./bin python 3 check.py
Test passed in CI: https://github.com/Unity-Technologies/binaryen/actions/runs/10078907940/job/27864951293?pr=6
Notes to reviewer
The failing tests can be ignored the jobs seem to be outdated.