Skip to content

Commit 4a496fb

Browse files
committed
- Change the scrape benchmark to use http requests and the same app that
we are using in the service. This will make the benchmark closer to what we are doing in real life. This also takes into account gzip compression and other small details. Signed-off-by: William Johnson <[email protected]>
1 parent 0a1b9e4 commit 4a496fb

File tree

7 files changed

+754
-3
lines changed

7 files changed

+754
-3
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
6+
pull_request:
7+
types: [opened, reopened, edited, synchronize]
8+
9+
defaults:
10+
run:
11+
shell: bash -eux {0}
12+
13+
jobs:
14+
generate_memory_flamegraph:
15+
name: Generate flamegraph
16+
permissions:
17+
checks: write
18+
pull-requests: write
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/checkout@v4
24+
with:
25+
repository: rust-lang/rustc-demangle
26+
path: rustc-demangle
27+
28+
- uses: actions/checkout@v4
29+
with:
30+
repository: KDE/heaptrack
31+
path: heaptrack
32+
33+
- uses: actions/checkout@v4
34+
with:
35+
repository: brendangregg/FlameGraph
36+
path: FlameGraph
37+
38+
- name: Install Rust
39+
uses: actions-rust-lang/setup-rust-toolchain@v1
40+
with:
41+
rustflags: ""
42+
43+
- name: Install dependencies
44+
run: |
45+
sudo apt-get update
46+
47+
# Install heaptrack dependencies
48+
sudo apt-get install -y \
49+
build-essential libssl-dev pkg-config curl git \
50+
cmake g++ libboost-dev libboost-iostreams-dev \
51+
libboost-program-options-dev libdw-dev libelf-dev \
52+
elfutils libunwind-dev zlib1g-dev binutils-dev \
53+
libiberty-dev libdebuginfod-dev libboost-system-dev \
54+
libboost-filesystem-dev libboost-thread-dev libboost-regex-dev
55+
56+
# Install rustfilt - used for demangling symbols
57+
cargo install rustfilt
58+
59+
- name: Build and install librustc_demangle.so
60+
run: |
61+
cd rustc-demangle
62+
cargo build -p rustc-demangle-capi --release
63+
sudo mv target/release/librustc_demangle.so /usr/lib
64+
65+
- name: Build and install heaptrack
66+
run: |
67+
cd heaptrack
68+
mkdir build && cd build
69+
70+
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr/local -DHEAPTRACK_USE_LIBUNWIND=ON -DHEAPTRACK_BUILD_PRINT_TRACES=ON
71+
72+
make -j$(nproc)
73+
sudo make install
74+
75+
- name: Build flamegraph
76+
run: |
77+
cargo build --profile profiling --test flamegraph_test
78+
env:
79+
RUSTFLAGS: "-C force-frame-pointers=yes -C symbol-mangling-version=v0"
80+
CARGO_PROFILE_RELEASE_DEBUG: true
81+
82+
- name: Build heaptrack data
83+
run: |
84+
export TEST_BINARY=$(find "$GITHUB_WORKSPACE/target/profiling/deps" -name "flamegraph_test-*" -type f -executable | head -1)
85+
86+
if [ -z "$TEST_BINARY" ]; then
87+
echo "Error: Could not find test binary"
88+
exit 1
89+
fi
90+
91+
"$TEST_BINARY" profile_with_flamegraph --ignored --no-capture | head -100
92+
93+
heaptrack --output heaptrack-data "$TEST_BINARY" --ignored profile_with_flamegraph
94+
env:
95+
CARGO_MANIFEST_DIR: "$GITHUB_WORKSPACE/lustrefs-exporter"
96+
97+
- name: Generate flamegraph
98+
run: |
99+
heaptrack_print --version
100+
HEAPTRACK_FILE=$(ls heaptrack-data.* | head -1)
101+
102+
echo "Writing flamegraph data to flamegraph-data.txt"
103+
heaptrack_print "$HEAPTRACK_FILE" -F flamegraph-data.txt > /dev/null
104+
echo "Done writing flamegraph data to flamegraph-data.txt: $?"
105+
106+
# Demangle symbols
107+
rustfilt < flamegraph-data.txt > demangled-flamegraph.txt
108+
109+
# Filter out stacks with less than 1000 allocations. This has to be done because there are so many
110+
# of them that flamegraph generation will fail.
111+
awk '$NF > 1000' demangled-flamegraph.txt > significant_stacks.txt
112+
113+
# Generate the flamegraph
114+
FlameGraph/flamegraph.pl --colors mem --countname allocations < significant_stacks.txt > flamegraph.svg
115+
116+
- name: Upload flamegraphs and heaptrack data
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: flamegraph
120+
path: |
121+
flamegraph.svg
122+
cpu-flamegraph.svg
123+
heaptrack-data.*

0 commit comments

Comments
 (0)