-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Simplify the use of emprofile and fix issue with empty generated profiles. #13464
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f30feaf
Simplify the use of emprofile and fix issue with empty generated prof…
juj e2678ac
Change EM_PROFILE_TOOLCHAIN environment variable to simpler "EMPROFIL…
juj 25d06e8
Add -c and -o flags and simplify generated profile filename
juj 5ea463e
Add mouse hover tooltips to emprofile results.
juj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/bin/sh | ||
| # Copyright 2020 The Emscripten Authors. All rights reserved. | ||
| # Emscripten is available under two separate licenses, the MIT license and the | ||
| # University of Illinois/NCSA Open Source License. Both these licenses can be | ||
| # found in the LICENSE file. | ||
| # | ||
| # Entry point for running python scripts on UNIX systems. | ||
| # | ||
| # To modify this file, edit `tools/run_python.sh` and then run | ||
| # `tools/create_entry_points.py` | ||
|
|
||
| if [ -z "$PYTHON" ]; then | ||
| PYTHON=$EMSDK_PYTHON | ||
| fi | ||
|
|
||
| if [ -z "$PYTHON" ]; then | ||
| PYTHON=$(which python3 2> /dev/null) | ||
| fi | ||
|
|
||
| if [ -z "$PYTHON" ]; then | ||
| PYTHON=$(which python 2> /dev/null) | ||
| fi | ||
|
|
||
| if [ -z "$PYTHON" ]; then | ||
| echo 'unable to find python in $PATH' | ||
| exit 1 | ||
| fi | ||
|
|
||
| exec "$PYTHON" "tools/$0.py" "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| :: Entry point for running python scripts on windows systems. | ||
| :: To modify this file, edit `tools/run_python.bat` and then run | ||
| :: `tools/create_entry_points.py` | ||
|
|
||
| @setlocal | ||
| @set EM_PY=%EMSDK_PYTHON% | ||
| @if "%EM_PY%"=="" ( | ||
| set EM_PY=python | ||
| ) | ||
|
|
||
| @"%EM_PY%" "%~dp0\tools\%~n0.py" %* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,32 +14,30 @@ To try out the toolchain profiler, run the following set of commands: | |
| .. code-block:: bash | ||
|
|
||
| cd path/to/emscripten | ||
| tools/emprofile.py --reset | ||
| export EM_PROFILE_TOOLCHAIN=1 | ||
| export EMPROFILE=1 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change the name of this environment variable? I myself only know of one user out there but there maybe be others.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #13464 (comment) |
||
| emcc tests/hello_world.c -O3 -o a.html | ||
| tools/emprofile.py --graph | ||
| emprofile | ||
|
|
||
| On Windows, replace the ``export`` keyword with ``set`` instead. The last command should generate a HTML file of form ``toolchain_profiler.results_yyyymmdd_hhmm.html`` that can be opened in the web browser to view the results. | ||
|
|
||
| Details | ||
| ======= | ||
|
|
||
| The toolchain profiler is active whenever the toolchain is invoked with the environment variable ``EM_PROFILE_TOOLCHAIN=1`` being set. In this mode, each called tool will accumulate profiling instrumentation data to a set of .json files under the Emscripten temp directory. | ||
| The toolchain profiler is active whenever the toolchain is invoked with the environment variable ``EMPROFILE=1`` being set. In this mode, each called tool will accumulate profiling instrumentation data to a set of .json files under the Emscripten temp directory. | ||
|
|
||
| Profiling Tool Commands | ||
| ----------------------- | ||
|
|
||
| The command ``tools/emprofile.py --reset`` deletes all previously stored profiling data. Call this command to erase the profiling session to a fresh empty state. To start profiling, call Emscripten tool commands with the environment variable ``EM_PROFILE_TOOLCHAIN=1`` set either system-wide as shown in the example, or on a per command basis, like this: | ||
| The command ``tools/emprofile.py --clear`` deletes all previously stored profiling data. Call this command to erase the profiling session to a fresh empty state. To start profiling, call Emscripten tool commands with the environment variable ``EMPROFILE=1`` set either system-wide as shown in the example, or on a per command basis, like this: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| cd path/to/emscripten | ||
| tools/emprofile.py --reset | ||
| EM_PROFILE_TOOLCHAIN=1 emcc tests/hello_world.c -o a.bc | ||
| EM_PROFILE_TOOLCHAIN=1 emcc a.bc -O3 -o a.html | ||
| tools/emprofile.py --graph --outfile=myresults.html | ||
| emprofile --clear | ||
| EMPROFILE=1 emcc -c foo.c a.o | ||
| EMPROFILE=1 emcc a.o -O3 -o a.html | ||
| emprofile --outfile=myresults.html | ||
|
|
||
| Any number of commands can be profiled within one session, and when ``tools/emprofile.py --graph`` is finally called, it will pick up records from all Emscripten tool invocations up to that point. Calling ``--graph`` also clears the recorded profiling data. | ||
| Any number of commands can be profiled within one session, and when ``emprofile`` is finally called, it will pick up records from all Emscripten tool invocations up to that point, graph them, and clear the recorded profiling data for the next run. | ||
|
|
||
| The output HTML filename can be chosen with the optional ``--outfile=myresults.html`` parameter. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You can create these while keeping the tool under tool if you like?
You can just add
tools/embuildertotools/create_entry_points.pyad then re-run it.These scripts will then get created in the
toolsdirectory, which I think it probably fine.If you really want to make it so that folks don't have to type
./tools/empofilebut just./emprofileI think there are a few other places in the docs that will need updating.I think it might be simple to leave it there myself but I don't have strong feelings.
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.
I do want the users to be able to run just
emprofileand not$EMSCRIPTEN/tools/emprofile, the earlier pattern to enable was too complex, and I had to always look at the doc page after a few months had passed since I used this tool. Now after this enabling the profiler should be much simpler.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.
OK sounds reasonable. Perhaps we need to modify create_entry_points.py to handle creating wrappers at the top level to tools in the
toolsdirectory. I can take a look at this if you like?Uh oh!
There was an error while loading. Please reload this page.
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.
Actually it looks like this would make the bat/sh run_python scripts way less trivial. Would you mind if we land this change without moving
emprofilleout of thetoolsdirectory.We can then followup with a plan to enable tools like
emdumpemprofileandfile_packagerto be moved to the top level at some point in the future? It seems like we should have a generic solution here.lgtm with
create_entry_points.pyusage and keeping launchers under tools. (for now)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.
I have that other PR for ccache that already rewrites parts of the scripts creation, I'd prefer not to have to manage conflicts here. Hoping this could land as-is..?
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.
I took a look at solution for the create_entry_points.py problem: #13679
Hopefully it will make this change easier.