From e333f29b335097a4bdfd883125013daa23d83d8a Mon Sep 17 00:00:00 2001 From: saleel Date: Fri, 31 Jan 2025 20:40:45 +0400 Subject: [PATCH] docs: add docs for aztec flamegraph (#11657) Co-authored-by: josh crites --- .../smart_contracts/profiling_transactions.md | 27 +++++++++++++++++++ .../developer_references/cli_reference.md | 7 +++++ 2 files changed, 34 insertions(+) diff --git a/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md b/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md index b07a332f5ac..66715f452e1 100644 --- a/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md +++ b/docs/docs/guides/developer_guides/smart_contracts/profiling_transactions.md @@ -69,3 +69,30 @@ Total gates: 329,558 Here you can see the gate count of each private function call in the transaction along with the kernel circuits needed in between, and the total gate count. This will help you understand which parts of your transaction are bottlenecks and optimize the contract logic accordingly. + + +## Flamegraph + +While the `aztec-wallet` provides a way to profile the gate count of each private function in a transaction, flamegraph tool lets you visualize the gate count of each operation within a private function. + +You can run the flamegraph tool by running the following command: + +```bash +aztec flamegraph +``` + +For example, if you want to flamegraph the `cast_vote` function [aztec-starter](https://github.com/AztecProtocol/aztec-starter/blob/main/src/main.nr), you can do + +```bash +aztec-nargo compile +aztec flamegraph target/easy_private_voting_contract-EasyPrivateVoting.json cast_vote +``` + +This will generate a flamegraph of the `cast_vote` function and save the output svg to the `target` directory. You can open the svg file in your browser to visualize the flamegraph. + +You can also run the same command with `SERVE=1` to serve the flamegraph on a local server. + +```bash +SERVE=1 aztec flamegraph target/easy_private_voting_contract-EasyPrivateVoting.json cast_vote +``` +This will serve the flamegraph on `http://localhost:8000`. diff --git a/docs/docs/reference/developer_references/cli_reference.md b/docs/docs/reference/developer_references/cli_reference.md index 1bb2392d3b7..85d7dae2169 100644 --- a/docs/docs/reference/developer_references/cli_reference.md +++ b/docs/docs/reference/developer_references/cli_reference.md @@ -238,6 +238,13 @@ Required option: ## Development and Debugging Tools +### flamegraph +Generates a flamegraph of the gate counts of a private function call. + +``` +[SERVE=1] aztec flamegraph +``` + ### codegen Validates and generates an Aztec Contract ABI from Noir ABI.