Skip to content

Commit 496e4b6

Browse files
authored
doc: Add DataFusion profiling documentation for MacOS (#9711)
* Add profiling doc for MacOS
1 parent 55aacf6 commit 496e4b6

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

docs/source/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Please see the `developer’s guide`_ for contributing and `communication`_ for
7979
.. toctree::
8080
:maxdepth: 1
8181
:caption: Library User Guide
82-
82+
8383
library-user-guide/index
8484
library-user-guide/using-the-sql-api
8585
library-user-guide/working-with-exprs
@@ -89,6 +89,7 @@ Please see the `developer’s guide`_ for contributing and `communication`_ for
8989
library-user-guide/adding-udfs
9090
library-user-guide/custom-table-providers
9191
library-user-guide/extending-operators
92+
library-user-guide/profiling
9293

9394
.. _toc.contributor-guide:
9495

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
# Profiling Cookbook
21+
22+
The section contains examples how to perform CPU profiling for Apache Arrow DataFusion on different operating systems.
23+
24+
## MacOS
25+
26+
### Building a flamegraph
27+
28+
- [cargo-flamegraph](https://github.com/flamegraph-rs/flamegraph)
29+
30+
Test:
31+
32+
```bash
33+
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root --unit-test datafusion -- dataframe::tests::test_array_agg
34+
```
35+
36+
Benchmark:
37+
38+
```bash
39+
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root --bench sql_planner -- --bench
40+
```
41+
42+
Open `flamegraph.svg` file with the browser
43+
44+
- dtrace with DataFusion CLI
45+
46+
```bash
47+
git clone https://github.com/brendangregg/FlameGraph.git /tmp/fg
48+
cd datafusion-cli
49+
CARGO_PROFILE_RELEASE_DEBUG=true cargo build --release
50+
echo "select * from table;" >> test.sql
51+
sudo dtrace -c './target/debug/datafusion-cli -f test.sql' -o out.stacks -n 'profile-997 /execname == "datafusion-cli"/ { @[ustack(100)] = count(); }'
52+
/tmp/fg/FlameGraph/stackcollapse.pl out.stacks | /tmp/fg/FlameGraph/flamegraph.pl > flamegraph.svg
53+
```
54+
55+
Open `flamegraph.svg` file with the browser
56+
57+
### CPU profiling with XCode Instruments
58+
59+
[Video: how to CPU profile DataFusion with XCode Instruments](https://youtu.be/P3dXH61Kr5U)
60+
61+
## Linux
62+
63+
## Windows

0 commit comments

Comments
 (0)