Git Product home page Git Product logo

instrumentstopprof's Introduction

InstrumentsToPprof

This is a tool used to convert performance profiles from Xcode's Instruments tool on macOS to pprof.

Getting started

First clone the repo,

$ git clone https://github.com/google/instrumentsToPprof.git

The tool requires Go, which can be downloaded at the Go homepage

instrumentsToPprof can be installed to the GOPATH using

go install github.com/google/instrumentsToPprof@latest

or run directly in the repo using

go run main.go

Producing pprof from deep copy

The tool's input is the copied data from Deep Copy inside Instruments. The Deep Copy must be from the Time Profile tool in instruments, and the selection roots must be processes.

To get started, make a trace, either using xctrace or in the Instruments app.

$ xcrun -r xctrace record --template 'Time Profiler' --all-processes --time-limit 5s --output 'profile.trace'

Open the trace in the Instruments tool, and select the process that you want to have converted. Multiple processes may be selected using Cmd+Shift+C. Then get the text data using Deep Copy in the Edit menu.

Paste the deep copy to a text file and run instrumentsToPprof which produces a file profile.pb.gz. This file can analyzed using the google/pprof tool.

$ instrumentsToPprof deep_copy_paste.txt

Alternatively, one can produce the profile.pb.gz by piping the clipboard directly into instrumentsToPprof

$ pbpaste | instrumentsToPpof

Producing a pprof from sample

instrumentsToPprof also supports output from the sample command on Mac.

To get a sample, run

$ sample <pid> -f <output-file>

and to produce a pprof from that sample, use the --format flag

$ instrumentsToPprof --format=sample <output-file>

Profiling Google Chrome

It's now possible to profile Google Chrome's various release channels (Stable, Beta, Dev, Canary) using instrumentsToPprof.

Use the new download_symbols.py script to download the symbols for the specific release version of Chrome you're profiling. For example:

download_symbols.py -v 115.0.5763.0 -o .

Then use Instruments' Time Profiler to gather a trace. Next, in Instruments, select File > Symbols.... Locate the Chrome or Chrome Helper process from which you wanted the trace; sometimes it's easiest to find this using Chrome's Task Manager, for example to find the PID of the GPU process. Then you can find the specific PID in Instruments' list.

Click "Locate" next to the dSYM path, and navigate to the directory the download_symbols.py script created.

At this point, the stack traces for this process should be well symbolized in Instruments. If so, proceed with the deep copy instructions above, and pprof's flame graphs will look good.

Disclaimer

This is not an officially supported Google product.

instrumentstopprof's People

Contributors

eshrubs avatar jiahaog avatar kenrussell avatar sunnyps avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.