-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add script for profiling self check (Linux only) #19322
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
Conversation
The script compiles mypy and profiles self check using the 'perf' profiler. Example of how to use this: ``` $ python misc/profile_self_check.py ... [will take several minutes] CPU profile collected. You can now analyze the profile: perf report -i mypy.profile.tmpdir/perf.data ```
misc/profile_self_check.py
Outdated
try: | ||
subprocess.run(["perf", "-h"], capture_output=True) | ||
except subprocess.CalledProcessError: | ||
print("error: The 'perf' profiler is not installed") | ||
sys.exit(1) |
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.
This should catch FileNotFoundError
to handle perf
not being found.
misc/profile_self_check.py
Outdated
try: | ||
subprocess.run(["clang", "--version"], capture_output=True) | ||
except subprocess.CalledProcessError: | ||
print("error: The clang compiler is not installed") | ||
sys.exit(1) |
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.
ditto
misc/profile_self_check.py
Outdated
- The tool prints a command that can be used to analyze the profile afterwards | ||
You may need to adjust kernel parameters temporarily, e.g. this (note that this has security | ||
impliciations): |
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.
impliciations): | |
implications): |
misc/profile_self_check.py
Outdated
target_dir = "." | ||
|
||
target_dir = "mypy.profile.tmpdir" |
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.
this looks off?
This speeds up self check by about 1.5% on my computer, according to `perf_compare.py`: ``` ... === Results === master 4.264s (0.0%) | stdev 0.024s HEAD 4.201s (-1.5%) | stdev 0.030s ``` I noticed this bottleneck when I was looking at a CPU profile generated using the script from #19322.
The script compiles mypy and profiles self check using the 'perf' profiler.
Example of how to use this: