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

feat: gperftools #3096

Merged
merged 10 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion barretenberg/cpp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ CMakeUserPresets.json
.vscode/settings.json
# to be unignored when we agree on clang-tidy rules
.clangd
acir_tests
acir_tests
# we may download go in scripts/collect_heap_information.sh
go*.tar.gz
22 changes: 17 additions & 5 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,18 @@
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "gperftools",
"displayName": "Debugging build with gperftools on Clang-16",
"description": "Build with gperf",
"inherits": "clang16",
"binaryDir": "build-gperftools",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_EXE_LINKER_FLAGS": "-ltcmalloc",
"CXXFLAGS": "-fno-omit-frame-pointer"
}
},
{
"name": "wasm",
"displayName": "Build for WASM",
Expand Down Expand Up @@ -283,6 +295,11 @@
"inherits": "clang16",
"configurePreset": "fuzzing"
},
{
"name": "gperftools",
"inherits": "clang16",
"configurePreset": "gperftools"
},
{
"name": "smt-verification",
"inherits": "clang16",
Expand Down Expand Up @@ -335,11 +352,6 @@
"name": "xray-1thread",
"configurePreset": "xray-1thread",
"inherits": "default"
},
{
"name": "xray",
"configurePreset": "xray",
"inherits": "default"
}
],
"testPresets": [
Expand Down
47 changes: 47 additions & 0 deletions barretenberg/cpp/scripts/collect_heap_information.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
set -eu

PRESET=gperftools
ONLY_PROCESS=${1:-}
EXECUTABLE=${2:-ultra_honk_rounds_bench}

# Move above script dir.
cd $(dirname $0)/..

# Configure and build with heap profiling preset.

cmake --preset $PRESET
cmake --build --preset $PRESET

cd build-$PRESET

if [ -z "$ONLY_PROCESS" ]; then
# Clear old heap profile data.
rm -f $EXECUTABLE.heap*

# Run application with heap profiling to a file with prefix '$EXECUTABLE'.
HEAPPROFILE=./$EXECUTABLE ./bin/$EXECUTABLE
fi

# Download and install Go
if [ ! -d ~/go ]; then
ARCHIVE=go1.21.3.linux-amd64.tar.gz
echo "Downloading and installing Go..."
wget https://go.dev/dl/$ARCHIVE
tar -C ~/ -xvf $ARCHIVE
rm $ARCHIVE
export PATH=$PATH:~/go/bin
fi

# Install pprof
if [ ! -f ~/go/bin/pprof ]; then
echo "Installing pprof..."
~/go/bin/go install github.com/google/pprof@latest
fi

# Collect the heap files
files=(./$EXECUTABLE.*.heap)
# Find the middle index based on the count
middle_index=$(( (${#files[@]} + 1) / 2 - 1))
# Process the heap profile with pprof
~/go/bin/pprof --text ./bin/$EXECUTABLE ${files[$middle_index]}