Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Add DataFusion profiling documentation for MacOS #9711

Merged
merged 6 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Please see the `developer’s guide`_ for contributing and `communication`_ for
.. toctree::
:maxdepth: 1
:caption: Library User Guide

library-user-guide/index
library-user-guide/using-the-sql-api
library-user-guide/working-with-exprs
Expand All @@ -89,6 +89,7 @@ Please see the `developer’s guide`_ for contributing and `communication`_ for
library-user-guide/adding-udfs
library-user-guide/custom-table-providers
library-user-guide/extending-operators
library-user-guide/profiling

.. _toc.contributor-guide:

Expand Down
62 changes: 62 additions & 0 deletions docs/source/library-user-guide/profiling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!---
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<!---
This file was generated by the dev/update_config_docs.sh script.
comphead marked this conversation as resolved.
Show resolved Hide resolved
Do not edit it manually as changes will be overwritten.
Instead, edit dev/update_config_docs.sh or the docstrings in datafusion/core/src/config.rs.
-->

# Profiling
comphead marked this conversation as resolved.
Show resolved Hide resolved

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

## MacOS

### Building a flamegraph

- [cargo-flamegraph](https://github.com/flamegraph-rs/flamegraph)
Example:

```bash
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root --unit-test datafusion -- dataframe::tests::test_xxx
comphead marked this conversation as resolved.
Show resolved Hide resolved
```

Open SVG file with the browser

- dtrace with DataFusion CLI

```bash
git clone https://github.com/brendangregg/FlameGraph.git /tmp/fg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite neat -- I did not know how to do this

cd datafusion-cli
CARGO_PROFILE_RELEASE_DEBUG=true cargo build --release
echo "select * from table;" >> test.sql
sudo dtrace -c './target/debug/datafusion-cli -f test.sql' -o out.stacks -n 'profile-997 /execname == "datafusion-cli"/ { @[ustack(100)] = count(); }'
/tmp/fg/FlameGraph/stackcollapse.pl out.stacks | /tmp/fg/FlameGraph/flamegraph.pl > flamegraph.svg
```

Open SVG file with the browser

### CPU profiling
comphead marked this conversation as resolved.
Show resolved Hide resolved

[Video: how to CPU profile DataFusion with XCode Instruments](https://youtu.be/P3dXH61Kr5U)

## Linux

## Windows
Loading