Generate a profile graph from strace log
Project description
straceprof
straceprof is a profiler designed for multi-process programs. straceprof
can take profile of any process when you can run it under strace. It is
particularly well-suited for profiling build processes such as those initiated
by make, cmake, shell scripts, or docker build.
Quick start
Run the following commands.
$ sudo apt-get install strace
$ pip install straceprof
$ strace \
--output=straceprof.log \
--trace=execve,execveat,exit,exit_group \
--follow-forks \
--string-limit=1000 \
--absolute-timestamps=format:unix,precision:us \
<command to profile>
$ straceprof \
--log=straceprof.log \
--output_image=straceprof.png
You will get a nice image!
Motivation
Software compilation often involves numerous processes, including compilers,
assemblers, linkers, and file copying operations. These processes are typically
coordinated using tools like make.
A common challenge in software development is the significant amount of time required to build software. For instance, building a programming language processor might take as long as 20 minutes. To expedite this process, it is essential to profile the build to pinpoint performance bottlenecks.
However, profiling build processes can be complex due to the wide range of build systems available. While some build systems incorporate built-in profiling capabilities, others do not. Furthermore, developers frequently combine multiple build systems using shell scripts or Dockerfile to construct a single software product.
To address these challenges, an effective profiler should be versatile and
user-friendly. It must be capable of analyzing entire build processes,
regardless of the underlying build system. Additionally, it should be suitable
for various environments, including CI systems like GitHub Actions and
containerized environments, where running privileged profilers such as perf
may be restricted.
In conclusion, we require a profiler that can be seamlessly integrated into diverse build processes without demanding elevated privileges.
Installation
On the computer you run the build process
For Ubuntu,
$ sudo apt-get install strace
I'm sure you can install strace on any other distributions easily.
On the computer you want to generate the profile image
$ pip install straceprof
Usage
First, you need to generate a strace log file. You can generate a strace log file using the following command:
strace \
--trace=execve,execveat,exit,exit_group \
--follow-forks \
--string-limit=1000 \
--absolute-timestamps=format:unix,precision:us \
--output=<path to strace log file> \
<command to profile>
Note
Do not change the options for strace command other than --output and
<command to profile>. straceprof assumes you run strace with these
options.
Then, you can generate a profile graph using the following command:
straceprof \
--log=<path to strace log file> \
--output_image=<path to output image file>
Other options are:
-h, --help show this help message and exit
--log LOG strace log file
--output_image OUTPUT_IMAGE
output plot file
--minimum_duration_sec MINIMUM_DURATION_SEC
The minimum duration of a process to be plotted. Shorter processes are omitted.
--title TITLE Title of the plot. When you don't specify this, the path to the log file is used.
--width WIDTH Width of the figure in pixels
--height HEIGHT Height of the figure in pixels
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file straceprof-0.0.3.tar.gz.
File metadata
- Download URL: straceprof-0.0.3.tar.gz
- Upload date:
- Size: 278.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0348b01d317b8aded91b407742870b84ec22e7aeeab24bd9c7f50104234a3f27
|
|
| MD5 |
4b80fc5c206592f6e490fcf3c3cfe72c
|
|
| BLAKE2b-256 |
411145cac3bbcb95854a268de6c2f10fc1f7b9ac90950e27fadbe9c0d1f5bb89
|
File details
Details for the file straceprof-0.0.3-py3-none-any.whl.
File metadata
- Download URL: straceprof-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bee63f5b4f1218d13576f798f1f455370a8de1c3dd3cdf6b36ae140262268a3e
|
|
| MD5 |
2ec83f5fa60e3604ef82c754fafd2e0b
|
|
| BLAKE2b-256 |
9ad980f1d534be8c73fbccb6ba1a8de97ee452e08b63f504473354813456e8cc
|