Skip to main content

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 install strace
$ pipx install git+https://github.com/akawashiro/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!

Example of straceprof output

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

$ pipx install git+https://github.com/akawashiro/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

straceprof-0.0.2.tar.gz (278.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

straceprof-0.0.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file straceprof-0.0.2.tar.gz.

File metadata

  • Download URL: straceprof-0.0.2.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

Hashes for straceprof-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5c7da41a9743eaa7aa7f9b7a7f8a83e843e6bb55e888e06180b08464f423c747
MD5 09b3d47026e18d6550efe35065404ce4
BLAKE2b-256 1780575e01cf38722639eb7a587dd4c61c2165211fba485f70a7b085dc824352

See more details on using hashes here.

File details

Details for the file straceprof-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: straceprof-0.0.2-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

Hashes for straceprof-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 025ef6ff29bf845db48afd9b68fc89b8f6ed5d1e4af5acac770c1eeb3fa9d211
MD5 a31ae9d999653daaa2213b602cd4ae00
BLAKE2b-256 13c71da032f081004988eb7599ddd7d586fef95dc51bcc6854d066e48547ebc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page