Skip to content

Commit 1a6ea60

Browse files
committed
WIP: initial edits to support new profiling image builds
1 parent 8ec7091 commit 1a6ea60

6 files changed

Lines changed: 91 additions & 2 deletions

File tree

scripts/docker/crossbuild.mk

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ DD:=$(CB_DIR)/crossbuild
2626
DOCKER_TMPL:=$(CB_DIR)/m4/Dockerfile.m4
2727

2828
# List of all the docker images (sorted for "crossbuild.info")
29-
CB_IMAGES:=$(sort $(patsubst $(DT)/%,%,$(wildcard $(DT)/*)))
29+
CB_IMAGES := $(sort $(filter-out profiling,\
30+
$(patsubst $(DT)/%,%,$(wildcard $(DT)/*/))))
3031

3132
# Location of the .git dir (may be different for e.g. submodules)
3233
GITDIR:=$(shell perl -MCwd -e 'print Cwd::abs_path shift' $$(git rev-parse --git-dir))
@@ -40,6 +41,8 @@ endif
4041
CB_IPREFIX:=freeradius40x-build
4142
CB_CPREFIX:=fr40x-crossbuild-
4243

44+
PROFILING_PROFILE ?= valgrind-callgrind
45+
4346
#
4447
# This Makefile is included in-line, and not via the "boilermake"
4548
# wrapper. But it's still useful to use the same process for
@@ -90,6 +93,23 @@ crossbuild.help: crossbuild.info
9093
@echo " crossbuild.IMAGE.clean - stop container and tidy up"
9194
@echo " crossbuild.IMAGE.wipe - remove Docker image"
9295
@echo ""
96+
@echo "Profiling targets:"
97+
@echo " crossbuild.IMAGE.profregen - regenerate Dockerfile.prof using default profile ($(PROFILING_PROFILE))"
98+
@echo " crossbuild.IMAGE.profregen PROFILING_PROFILE=<name> - regenerate using a specific profile"
99+
@echo " crossbuild.IMAGE.profbuild - build profiling image using default profile ($(PROFILING_PROFILE))"
100+
@echo " crossbuild.IMAGE.profbuild PROFILING_PROFILE=<name> - build using a specific profile"
101+
@echo ""
102+
@echo "Available profiling profiles (scripts/docker/profiling/profiles/):"
103+
@echo " valgrind-callgrind - callgrind call graph and instruction profiling"
104+
@echo " valgrind-massif - FUTURE: massif heap memory profiling"
105+
@echo " gperftools-cpu - FUTURE: gperftools CPU profiling"
106+
@echo ""
107+
@echo "Profiling image profregen/profbuild examples:"
108+
@echo " make crossbuild.ubuntu24.profregen"
109+
@echo " make crossbuild.ubuntu24.profregen PROFILING_PROFILE=valgrind-callgrind"
110+
@echo " make crossbuild.ubuntu24.profbuild"
111+
@echo " make crossbuild.ubuntu24.profbuild PROFILING_PROFILE=gperftools-cpu"
112+
@echo ""
93113
@echo "Use 'make NOCACHE=1 ...' to disregard the Docker cache on build"
94114

95115
#
@@ -140,6 +160,20 @@ $(DD)/stamp-image.${1}:
140160
${Q}docker build $(DOCKER_BUILD_OPTS) $(DT)/${1} -f $(DT)/${1}/Dockerfile.cb -t $(CB_IPREFIX)/${1} >$(DD)/build.${1} 2>&1
141161
${Q}touch $(DD)/stamp-image.${1}
142162

163+
#
164+
# Build the profiling image
165+
#
166+
.PHONY: crossbuild.${1}.profbuild
167+
crossbuild.${1}.profbuild: $(DD)/stamp-image.${1}-profbuild
168+
169+
$(DD)/stamp-image.${1}-profbuild: $(DT)/${1}/Dockerfile.prof
170+
${Q}echo "BUILD ${1} ($(CB_IPREFIX)/${1}-prof) > $(DD)/build.${1}-profbuild"
171+
${Q}docker build $(DOCKER_BUILD_OPTS) $(DT)/${1} \
172+
-f $(DT)/${1}/Dockerfile.prof \
173+
-t $(CB_IPREFIX)/${1}-prof \
174+
>$(DD)/build.${1}-profbuild 2>&1
175+
${Q}touch $(DD)/stamp-image.${1}-profbuild
176+
143177
#
144178
# Start up the docker container
145179
#
@@ -249,6 +283,21 @@ $(DT)/${1}/Dockerfile.cb: $(DOCKER_TMPL) $(CB_DIR)/m4/crossbuild.deb.m4 $(CB_DIR
249283
${Q}echo REGEN ${1}
250284
${Q}m4 -I $(CB_DIR)/m4 -D D_NAME=${1} -D D_TYPE=crossbuild $$< > $$@
251285

286+
#
287+
# Regenerate Dockerfile.prof from m4 template
288+
#
289+
.PHONY: crossbuild.${1}.profregen
290+
crossbuild.${1}.profregen: $(DT)/${1}/Dockerfile.prof
291+
292+
$(DT)/${1}/Dockerfile.prof: $(DOCKER_TMPL) $(CB_DIR)/m4/profiling.deb.m4 $(CB_DIR)/m4/profiling.rpm.m4
293+
${Q}echo REGEN ${1}
294+
${Q}m4 -I $(CB_DIR)/m4 \
295+
-D D_NAME=${1} \
296+
-D D_TYPE=profiling \
297+
-D CB_IMAGE=$(CB_IPREFIX)/${1} \
298+
-D PROFILING_PROFILE_NAME=$(PROFILING_PROFILE) \
299+
$$< > $$@
300+
252301
#
253302
# Run the build test
254303
#

scripts/docker/docker.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ DT:=$(CB_DIR)/build
2222
DOCKER_TMPL:=$(CB_DIR)/m4/Dockerfile.m4
2323

2424
# List of all the docker images (sorted for "docker.info")
25-
IMAGES:=$(sort $(patsubst $(DT)/%,%,$(wildcard $(DT)/*)))
25+
IMAGES:=$(sort $(filter-out profiling,$(patsubst $(DT)/%,%,$(wildcard $(DT)/*))))
2626

2727
# Don't use the Docker cache if asked
2828
ifneq "$(NOCACHE)" ""

scripts/docker/m4/crossbuild.deb.m4

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ RUN apt-get update && \
2727
rm -r /var/lib/apt/lists/*
2828

2929

30+
#
31+
# Install profiling tools
32+
#
33+
RUN apt-get update && \
34+
apt-get install $APT_OPTS \
35+
libgoogle-perftools-dev \
36+
google-perftools \
37+
valgrind \
38+
heaptrack \
39+
psmisc \
40+
kcachegrind \
41+
kio \
42+
libkf5iconthemes5 \
43+
libkf5parts5 \
44+
libkf5textwidgets5 \
45+
libqt5gui5 \
46+
libqt5widgets5
47+
3048
#
3149
# Set up NetworkRADIUS extras repository
3250
#

scripts/docker/m4/profiling.deb.m4

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARG from=CB_IMAGE
2+
FROM ${from}
3+
4+
# Copy profiling profile scripts into the container
5+
COPY /scripts/docker/profiling/profiles/PROFILING_PROFILE_NAME /profiling
6+
7+
RUN /profiling/configure-cmd
8+
RUN make
9+
10+
WORKDIR /
11+
COPY scripts/docker/etc/docker-entrypoint.sh.PKG_TYPE docker-entrypoint.sh
12+
RUN chmod +x docker-entrypoint.sh
13+
14+
EXPOSE 1812/udp 1813/udp
15+
ENTRYPOINT ["/docker-entrypoint.sh"]
16+
CMD ["/profiling/start-cmd"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
./configure --enable-developer --disable-verify-ptr \
3+
CFLAGS="-g3 -O1 -fno-omit-frame-pointer" \
4+
LDFLAGS="-fno-omit-frame-pointer"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
valgrind --tool=callgrind scripts/bin/radiusd -f -l stdout -S resources.talloc_skip_cleanup=yes

0 commit comments

Comments
 (0)