|
| 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