Skip to content

Commit a16694f

Browse files
committed
New profiling images based off of crossbuild images
1 parent 049a23e commit a16694f

3 files changed

Lines changed: 264 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Auto generated for ubuntu24
2+
# from scripts/docker/m4/profiling.deb.m4
3+
#
4+
# Rebuild this file with `make profiling.ubuntu24.regen`
5+
#
6+
ARG from=freeradius40x-build/ubuntu24
7+
FROM ${from}
8+
9+
#
10+
# Install profiling tools
11+
#
12+
# Valgrind/cachegrind
13+
# kcachegrind + KDE/Qt libs
14+
# gperftools
15+
# heaptrack
16+
#
17+
RUN apt-get update && \
18+
apt-get install -y $APT_OPTS \
19+
libgoogle-perftools-dev \
20+
google-perftools \
21+
valgrind \
22+
heaptrack \
23+
psmisc \
24+
kcachegrind \
25+
kio \
26+
libkf5iconthemes5 \
27+
libkf5parts5 \
28+
libkf5textwidgets5 \
29+
libqt5gui5 \
30+
libqt5widgets5 && \
31+
apt-get clean && \
32+
rm -r /var/lib/apt/lists/*
33+
34+
#
35+
# Set up Ubuntu debug symbol repository and install OS library debug symbols.
36+
# These allow profiling tools to resolve system library calls.
37+
#
38+
RUN apt-get update && \
39+
apt-get install -y $APT_OPTS ubuntu-dbgsym-keyring && \
40+
printf 'deb http://ddebs.ubuntu.com noble main restricted universe multiverse\ndeb http://ddebs.ubuntu.com noble-updates main restricted universe multiverse\n' \
41+
> /etc/apt/sources.list.d/ddebs.list && \
42+
apt-get update && \
43+
for pkg in \
44+
libc6-dbg \
45+
zlib1g-dbgsym \
46+
libreadline8t64-dbgsym \
47+
libssl3t64-dbgsym \
48+
libsasl2-2-dbgsym \
49+
libpam0g-dbgsym \
50+
libldap2-dbgsym \
51+
libtalloc2-dbgsym \
52+
libpcre2-8-0-dbgsym \
53+
libpcap0.8t64-dbgsym \
54+
libunbound8-dbgsym \
55+
libsqlite3-0-dbgsym \
56+
libpq5-dbgsym \
57+
libmariadb3-dbgsym \
58+
libgdbm6t64-dbgsym \
59+
libjson-c5-dbgsym \
60+
libbrotli1-dbgsym \
61+
libhiredis1.1.0-dbgsym \
62+
librdkafka1-dbgsym \
63+
libwbclient0-dbgsym \
64+
libcurl4t64-dbgsym; do \
65+
apt-get install -y $APT_OPTS $pkg || echo "WARNING: could not install dbgsym package: $pkg"; \
66+
done && \
67+
apt-get clean && \
68+
rm -r /var/lib/apt/lists/*
69+
70+
#
71+
# Rebuild libkqueue from source with debug symbols.
72+
# CMAKE_BUILD_TYPE must be explicitly set to prevent
73+
# the libkqueue project from overriding the flags.
74+
# libkqueue source currently uses "-O2 -g -DNDEBUG" by default.
75+
#
76+
RUN apt-get update && \
77+
apt-get install -y $APT_OPTS --no-install-recommends cmake git && \
78+
apt-get clean && \
79+
rm -r /var/lib/apt/lists/* && \
80+
git clone --depth 1 https://github.com/mheily/libkqueue.git /tmp/libkqueue && \
81+
cd /tmp/libkqueue && \
82+
cmake -G "Unix Makefiles" \
83+
-DCMAKE_INSTALL_PREFIX=/usr \
84+
-DCMAKE_INSTALL_LIBDIR=lib \
85+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
86+
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g3 -O1 -fno-omit-frame-pointer -DNDEBUG" \
87+
. && \
88+
make && \
89+
cpack -G DEB && \
90+
dpkg -i *.deb && \
91+
cd / && rm -rf /tmp/libkqueue
92+
93+
#
94+
# Install FlameGraph
95+
#
96+
RUN git clone --depth 1 https://github.com/brendangregg/FlameGraph /opt/flamegraph \
97+
&& chmod +x /opt/flamegraph/*.pl /opt/flamegraph/*.sh
98+
99+
# Add FlameGraph to path
100+
ENV PATH="/opt/flamegraph:${PATH}"
101+
102+
#
103+
# Install Inferno for callgrind. Inferno is a Rust port of FlameGraph with broader format support
104+
#
105+
RUN apt-get update && \
106+
apt-get install -y $APT_OPTS --no-install-recommends \
107+
cargo && \
108+
cargo install inferno --version 0.11.21 --locked --root /usr/local && \
109+
apt-get clean && \
110+
rm -r /var/lib/apt/lists/*
111+
112+
EXPOSE 1812/udp 1813/udp
113+
CMD ["/bin/sh", "-c", "while true; do sleep 60; done"]

scripts/docker/crossbuild.mk

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ endif
4242
CB_IPREFIX:=freeradius40x-build
4343
CB_CPREFIX:=fr40x-crossbuild-
4444

45+
PROFILE ?= default-profiling
46+
4547
#
4648
# This Makefile is included in-line, and not via the "boilermake"
4749
# wrapper. But it's still useful to use the same process for
@@ -92,6 +94,11 @@ crossbuild.help: crossbuild.info
9294
@echo " crossbuild.IMAGE.clean - stop container and tidy up"
9395
@echo " crossbuild.IMAGE.distclean - remove Docker image"
9496
@echo ""
97+
@echo "Profiling targets:"
98+
@echo " crossbuild.IMAGE.profile.regen - regenerate Dockerfile.prof"
99+
@echo " crossbuild.IMAGE.profile.build - build profiling image"
100+
@echo " crossbuild.IMAGE.profile.reset - remove profiling stamp to force rebuild"
101+
@echo ""
95102
@echo "Use 'make NOCACHE=1 ...' to disregard the Docker cache on build"
96103

97104
#
@@ -147,6 +154,19 @@ $(DD)/stamp-image.${1}:
147154
${Q}docker build $(DOCKER_BUILD_OPTS) $(if $(CB_FROM_${1}),--build-arg=from=$(CB_FROM_${1})) $(DT)/${1} -f $(DT)/${1}/Dockerfile.cb -t $(CB_IPREFIX)/${1} >$(DD)/build.${1} 2>&1
148155
${Q}touch $(DD)/stamp-image.${1}
149156

157+
#
158+
# Build the profiling image
159+
#
160+
crossbuild.${1}.profile.build: $(DD)/stamp-image.${1}-profile.build
161+
162+
$(DD)/stamp-image.${1}-profile.build: $(DT)/${1}/Dockerfile.prof
163+
${Q}echo "BUILD ${1} (freeradius4-$(PROFILE)/${1}) > $(DD)/build.${1}-profile.build"
164+
${Q}docker build $(DOCKER_BUILD_OPTS) . \
165+
-f $(DT)/${1}/Dockerfile.prof \
166+
-t freeradius4-$(PROFILE)/${1} \
167+
>$(DD)/build.${1}-profile.build 2>&1
168+
${Q}touch $(DD)/stamp-image.${1}-profile.build
169+
150170
#
151171
# Start up the docker container
152172
#
@@ -256,6 +276,29 @@ $(DT)/${1}/Dockerfile.cb: $(DOCKER_TMPL) $(CB_DIR)/m4/crossbuild.deb.m4 $(CB_DIR
256276
${Q}echo REGEN ${1}
257277
${Q}m4 -I $(CB_DIR)/m4 -D D_NAME=${1} -D D_TYPE=crossbuild $$< > $$@
258278

279+
#
280+
# Regenerate Dockerfile.prof from m4 template
281+
#
282+
.PHONY: crossbuild.${1}.profile.regen
283+
crossbuild.${1}.profile.regen: $(DT)/${1}/Dockerfile.prof
284+
285+
$(DT)/${1}/Dockerfile.prof: $(DOCKER_TMPL) $(CB_DIR)/m4/profiling.deb.m4
286+
${Q}echo REGEN ${1}
287+
${Q}m4 -I $(CB_DIR)/m4 \
288+
-D D_NAME=${1} \
289+
-D D_TYPE=profiling \
290+
-D CB_IMAGE=$(CB_IPREFIX)/${1} \
291+
-D PROFILE_NAME=$(PROFILE) \
292+
$$< > $$@
293+
294+
#
295+
# Remove profiling stamp so next profile.build starts clean
296+
#
297+
.PHONY: crossbuild.${1}.profile.reset
298+
crossbuild.${1}.profile.reset:
299+
${Q}echo RESET profiling ${1}
300+
${Q}rm -f $(DD)/stamp-image.${1}-profile.build
301+
259302
#
260303
# Run the build test
261304
#

scripts/docker/m4/profiling.deb.m4

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
ARG from=CB_IMAGE
2+
FROM ${from}
3+
4+
#
5+
# Install profiling tools
6+
#
7+
# Valgrind/cachegrind
8+
# kcachegrind + KDE/Qt libs
9+
# gperftools
10+
# heaptrack
11+
#
12+
RUN apt-get update && \
13+
apt-get install -y $APT_OPTS \
14+
libgoogle-perftools-dev \
15+
google-perftools \
16+
valgrind \
17+
heaptrack \
18+
psmisc \
19+
kcachegrind \
20+
kio \
21+
libkf5iconthemes5 \
22+
libkf5parts5 \
23+
libkf5textwidgets5 \
24+
libqt5gui5 \
25+
libqt5widgets5 && \
26+
apt-get clean && \
27+
rm -r /var/lib/apt/lists/*
28+
29+
#
30+
# Set up Ubuntu debug symbol repository and install OS library debug symbols.
31+
# These allow profiling tools to resolve system library calls.
32+
#
33+
RUN apt-get update && \
34+
apt-get install -y $APT_OPTS ubuntu-dbgsym-keyring && \
35+
printf 'deb http://ddebs.ubuntu.com OS_CODENAME main restricted universe multiverse\ndeb http://ddebs.ubuntu.com OS_CODENAME-updates main restricted universe multiverse\n' \
36+
> /etc/apt/sources.list.d/ddebs.list && \
37+
apt-get update && \
38+
for pkg in \
39+
libc6-dbg \
40+
zlib1g-dbgsym \
41+
libreadline8t64-dbgsym \
42+
libssl3t64-dbgsym \
43+
libsasl2-2-dbgsym \
44+
libpam0g-dbgsym \
45+
libldap2-dbgsym \
46+
libtalloc2-dbgsym \
47+
libpcre2-8-0-dbgsym \
48+
libpcap0.8t64-dbgsym \
49+
libunbound8-dbgsym \
50+
libsqlite3-0-dbgsym \
51+
libpq5-dbgsym \
52+
libmariadb3-dbgsym \
53+
libgdbm6t64-dbgsym \
54+
libjson-c5-dbgsym \
55+
libbrotli1-dbgsym \
56+
libhiredis1.1.0-dbgsym \
57+
librdkafka1-dbgsym \
58+
libwbclient0-dbgsym \
59+
libcurl4t64-dbgsym; do \
60+
apt-get install -y $APT_OPTS $pkg || echo "WARNING: could not install dbgsym package: $pkg"; \
61+
done && \
62+
apt-get clean && \
63+
rm -r /var/lib/apt/lists/*
64+
65+
#
66+
# Rebuild libkqueue from source with debug symbols.
67+
# CMAKE_BUILD_TYPE must be explicitly set to prevent
68+
# the libkqueue project from overriding the flags.
69+
# libkqueue source currently uses "-O2 -g -DNDEBUG" by default.
70+
#
71+
RUN apt-get update && \
72+
apt-get install -y $APT_OPTS --no-install-recommends cmake git && \
73+
apt-get clean && \
74+
rm -r /var/lib/apt/lists/* && \
75+
git clone --depth 1 https://github.com/mheily/libkqueue.git /tmp/libkqueue && \
76+
cd /tmp/libkqueue && \
77+
cmake -G "Unix Makefiles" \
78+
-DCMAKE_INSTALL_PREFIX=/usr \
79+
-DCMAKE_INSTALL_LIBDIR=lib \
80+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
81+
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g3 -O1 -fno-omit-frame-pointer -DNDEBUG" \
82+
. && \
83+
make && \
84+
cpack -G DEB && \
85+
dpkg -i *.deb && \
86+
cd / && rm -rf /tmp/libkqueue
87+
88+
#
89+
# Install FlameGraph
90+
#
91+
RUN git clone --depth 1 https://github.com/brendangregg/FlameGraph /opt/flamegraph \
92+
&& chmod +x /opt/flamegraph/*.pl /opt/flamegraph/*.sh
93+
94+
# Add FlameGraph to path
95+
ENV PATH="/opt/flamegraph:${PATH}"
96+
97+
#
98+
# Install Inferno for callgrind. Inferno is a Rust port of FlameGraph with broader format support
99+
#
100+
RUN apt-get update && \
101+
apt-get install -y $APT_OPTS --no-install-recommends \
102+
cargo && \
103+
cargo install inferno --version 0.11.21 --locked --root /usr/local && \
104+
apt-get clean && \
105+
rm -r /var/lib/apt/lists/*
106+
107+
EXPOSE 1812/udp 1813/udp
108+
CMD ["/bin/sh", "-c", "while true; do sleep 60; done"]

0 commit comments

Comments
 (0)