Skip to content

Commit f190fc6

Browse files
authored
feat: Updating flamegraph docs (#13299)
* Updating flamegraph
1 parent 192079e commit f190fc6

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

docs/source/library-user-guide/profiling.md

+24-10
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
The section contains examples how to perform CPU profiling for Apache DataFusion on different operating systems.
2323

24-
## MacOS
25-
2624
### Building a flamegraph
2725

2826
[Video: how to CPU profile DataFusion with a Flamegraph](https://youtu.be/2z11xtYw_xs)
@@ -34,31 +32,47 @@ in images such as this:
3432

3533
![Flamegraph](../_static/images/flamegraph.svg)
3634

37-
To create a flamegraph, you need to install the `flamegraph` tool:
35+
## MacOS
36+
37+
#### Step 1: Install the flamegraph Tool
38+
39+
To install flamegraph, run:
3840

3941
```shell
4042
cargo install flamegraph
4143
```
4244

43-
Then you can run the flamegraph tool with the `--` separator to pass arguments
44-
to the binary you want to profile.
45+
#### Step 2: Prepare Your Environment
46+
47+
Ensure that you're in the directory containing the necessary data files for your DataFusion query. The flamegraph tool will profile the execution of your query against this data.
48+
49+
#### Step 3: Running the Flamegraph Tool
50+
51+
To generate a flamegraph, you'll need to use the -- separator to pass arguments to the binary you're profiling. For datafusion-cli, you need to make sure to run the command with sudo permissions (especially on macOS, where DTrace requires elevated privileges).
52+
53+
Here is a general example:
54+
55+
```shell
56+
sudo flamegraph -- datafusion-cli -f <path_to_sql_file/sql_file.sql>
57+
```
58+
59+
#### Example: Generating a Flamegraph for a Specific Query
4560

46-
Example: Flamegraph for `datafusion-cli` executing `q28.sql`. Note this
47-
must be run as root on Mac OSx to access DTrace.
61+
Here is an example using `28.sql`:
4862

4963
```shell
50-
sudo flamegraph -- datafusion-cli -f q28.sql
64+
sudo flamegraph -- datafusion-cli -f 28.sql
5165
```
5266

5367
You can also invoke the flamegraph tool with `cargo` to profile a specific test or benchmark.
5468

55-
Example: Flamegraph for a specific test:
69+
#### Example: Flamegraph for a specific test:
5670

5771
```bash
5872
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root --unit-test datafusion -- dataframe::tests::test_array_agg
5973
```
6074

61-
Example: Flamegraph for a benchmark
75+
#### Example: Flamegraph for a benchmark
6276

6377
```bash
6478
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root --bench sql_planner -- --bench

0 commit comments

Comments
 (0)