-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bb): integrate tracy memory/cpu profiler (#7718)
This is an in-depth profiler that has a bit of a learning curve but has really good thorough results ![image](https://github.com/user-attachments/assets/156c70ba-c7c5-4eab-94c2-f375b867381c)
- Loading branch information
Showing
14 changed files
with
164 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include(FetchContent) | ||
|
||
# Find the path where we will download the Tracy github repository | ||
# we need this to find where the Tracy header files are for inclusion. | ||
set(TRACY_INCLUDE "${CMAKE_BINARY_DIR}/_deps/tracy-src/public") | ||
|
||
# Work around an issue finding threads. | ||
set(CMAKE_THREAD_LIBS_INIT "-lpthread") | ||
|
||
# Download the Tracy github project and do an add_subdirectory on it. | ||
FetchContent_Declare(tracy | ||
GIT_REPOSITORY https://github.com/wolfpld/tracy | ||
GIT_TAG ffb98a972401c246b2348fb5341252e2ba855d00 | ||
SYSTEM # optional, the tracy include directory will be treated as system directory | ||
) | ||
FetchContent_MakeAvailable(tracy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
# NOTE: intended to be ran from one's external computer, connecting to Aztec mainframe | ||
# the benchmark runs with headless capture and then we copy the trace file and run tracy profiler | ||
# This is thus only really useful internally at Aztec, sorry external folks. It can be easily tweaked | ||
# however for any SSH setup, especially an ubuntu one, and of course if you are just tracing on the | ||
# same machine you can use the normal interactive tracy workflow. | ||
set -eux | ||
USER=$1 | ||
BOX=$USER-box | ||
BENCHMARK=${2:-ultra_plonk_bench} | ||
COMMAND=${3:-./bin/$BENCHMARK} | ||
|
||
ssh $BOX " | ||
set -eux ; | ||
! [ -d ~/tracy ] && git clone https://github.com/wolfpld/tracy ~/tracy ; | ||
cd ~/tracy/capture ; | ||
sudo apt-get install libdbus-1-dev libdbus-glib-1-dev ; | ||
mkdir -p build && cd build && cmake .. && make -j ; | ||
./tracy-capture -a 127.0.0.1 -f -o trace-$BENCHMARK & ; | ||
sleep 0.1 ; | ||
cd ~/aztec-packages/barretenberg/cpp/ ; | ||
cmake --preset tracy && cmake --build --preset tracy --parallel $BENCHMARK ; | ||
cd build-tracy ; | ||
ninja $BENCHMARK ; | ||
$COMMAND ; | ||
" | ||
! [ -d ~/tracy ] && git clone https://github.com/wolfpld/tracy ~/tracy | ||
cd ~/tracy | ||
cmake -B profiler/build -S profiler -DCMAKE_BUILD_TYPE=Release | ||
cmake --build profiler/build --parallel | ||
scp $BOX:/mnt/user-data/$USER/tracy/capture/build/trace-$BENCHMARK . | ||
~/tracy/profiler/build/tracy-profiler trace-$BENCHMARK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "barretenberg/common/mem.hpp" | ||
|
||
void* operator new(std::size_t count) | ||
{ | ||
// NOLINTBEGIN(cppcoreguidelines-no-malloc) | ||
void* ptr = malloc(count); | ||
// NOLINTEND(cppcoreguidelines-no-malloc) | ||
TRACY_ALLOC(ptr, count); | ||
return ptr; | ||
} | ||
|
||
void operator delete(void* ptr) noexcept | ||
{ | ||
TRACY_FREE(ptr); | ||
// NOLINTBEGIN(cppcoreguidelines-no-malloc) | ||
free(ptr); | ||
// NOLINTEND(cppcoreguidelines-no-malloc) | ||
} | ||
|
||
void operator delete(void* ptr, std::size_t size) noexcept | ||
{ | ||
static_cast<void>(size); // unused | ||
TRACY_FREE(ptr); | ||
// NOLINTBEGIN(cppcoreguidelines-no-malloc) | ||
free(ptr); | ||
// NOLINTEND(cppcoreguidelines-no-malloc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters