Skip to content

Commit

Permalink
Update xcode-instruments.md (MystenLabs#3075)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clay-Mysten authored Jul 7, 2022
1 parent 6b0d5b5 commit ffb2d40
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions doc/src/contribute/xcode-instruments.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
---
title: Profiling Sui on Mac OS using XCode instruments.
title: Profiling Sui on macOS using XCode Instruments
---

To profile on Mac OS:

* Install XCode: https://apps.apple.com/us/app/xcode/id497799835?mt=12
* Make sure you have the command line tools but running `xcode-select install`. If it says they are already installed you may want to go directly to https://developer.apple.com/download/more/ and download the .pkg for the commandline tools to make sure they are up to date.
* Add `/Applications/Xcode.app/Contents/Developer/usr/bin` to your `$PATH`.
* Build whatever Sui component you want to run normally with `cargo build` - these docs assume `target/debug/sui`.
* Sign the binary you wish to profile:
* Create a file called `debug.plist` with the following contents:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.security.get-task-allow</key><true/></dict></plist>

* Run:
$ codesign -s - -v -f --entitlements ../debug.plist target/debug/sui
* Now run the app and record a trace (select the most appropriate template, see xcode documentation for available templates).

To profile on macOS:

1. Install XCode: https://apps.apple.com/us/app/xcode/id497799835?mt=12
1. Make sure you have the command line tools by running `xcode-select install`. If it says they are already installed, you may want to go directly to https://developer.apple.com/download/more/ and download the `.pkg` for the command line tools to make sure they are up to date.
1. Add `/Applications/Xcode.app/Contents/Developer/usr/bin` to your `$PATH`.
1. Build whatever Sui component you want to run normally with `cargo build` - these docs assume `target/debug/sui`.
1. Sign the binary you wish to profile:
1. Create a file called `debug.plist` with the following contents:
```shell
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.security.get-task-allow</key><true/></dict></plist>
```
1. Run:
```shell
$ codesign -s - -v -f --entitlements ../debug.plist target/debug/sui
```
1. Run the app and record a trace (select the most appropriate template; see xcode documentation for available templates):
```shell
$ xcrun xctrace record --template 'Allocations' --launch -- ./target/debug/sui start
```

* Ctrl-C the app when you've recorded enough.
* It will write a directory starting with `Launch_` - run:

$ open Launch_xxxxxxxx
1. Ctrl-C the app when you've recorded enough.
1. It will write a directory starting with `Launch_` - run:
```shell
$ open Launch_xxxxxxxx
```
* The trace should open in XCode.
1. The trace should open in XCode.

0 comments on commit ffb2d40

Please sign in to comment.