This is an automated email from the ASF dual-hosted git repository.
comphead pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 496e4b67a0 doc: Add DataFusion profiling documentation for MacOS
(#9711)
496e4b67a0 is described below
commit 496e4b67a05bb49af8d7aa1ca5035312fd4e54f9
Author: comphead <[email protected]>
AuthorDate: Wed Mar 20 13:32:15 2024 -0700
doc: Add DataFusion profiling documentation for MacOS (#9711)
* Add profiling doc for MacOS
---
docs/source/index.rst | 3 +-
docs/source/library-user-guide/profiling.md | 63 +++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/docs/source/index.rst b/docs/source/index.rst
index f7c0873f3a..919a7ad703 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -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
@@ -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:
diff --git a/docs/source/library-user-guide/profiling.md
b/docs/source/library-user-guide/profiling.md
new file mode 100644
index 0000000000..a20489496f
--- /dev/null
+++ b/docs/source/library-user-guide/profiling.md
@@ -0,0 +1,63 @@
+<!---
+ 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.
+-->
+
+# Profiling Cookbook
+
+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)
+
+Test:
+
+```bash
+CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root --unit-test
datafusion -- dataframe::tests::test_array_agg
+```
+
+Benchmark:
+
+```bash
+CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --root --bench sql_planner
-- --bench
+```
+
+Open `flamegraph.svg` file with the browser
+
+- dtrace with DataFusion CLI
+
+```bash
+git clone https://github.com/brendangregg/FlameGraph.git /tmp/fg
+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 `flamegraph.svg` file with the browser
+
+### CPU profiling with XCode Instruments
+
+[Video: how to CPU profile DataFusion with XCode
Instruments](https://youtu.be/P3dXH61Kr5U)
+
+## Linux
+
+## Windows