Skip to content

Commit 1bfd0a3

Browse files
committed
configure.sh and start.sh scripts now included in profiling image build
1 parent ff45c05 commit 1bfd0a3

6 files changed

Lines changed: 86 additions & 5 deletions

File tree

scripts/docker/build/ubuntu24/Dockerfile.prof

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
ARG from=freeradius40x-build/ubuntu24
77
FROM ${from}
88

9+
# Copy profiling profile scripts into the container
10+
COPY scripts/docker/profiling/profiles/default-profiling /profile
11+
912
#
1013
# Install profiling tools
1114
#
@@ -51,7 +54,6 @@ RUN apt-get update && \
5154
libtalloc2-dbgsym \
5255
libpcre2-8-0-dbgsym \
5356
libpcap0.8t64-dbgsym \
54-
libcurl4t64-dbgsym \
5557
libunbound8-dbgsym \
5658
libsqlite3-0-dbgsym \
5759
libpq5-dbgsym \
@@ -62,6 +64,7 @@ RUN apt-get update && \
6264
libhiredis1.1.0-dbgsym \
6365
librdkafka1-dbgsym \
6466
libwbclient0-dbgsym && \
67+
(apt-get install -y $APT_OPTS libcurl4t64-dbgsym || true) && \
6568
apt-get clean && \
6669
rm -r /var/lib/apt/lists/*
6770

scripts/docker/m4/profiling.deb.m4

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
ARG from=CB_IMAGE
22
FROM ${from}
33

4+
# Copy profiling profile scripts into the container
5+
COPY scripts/docker/profiling/profiles/PROFILE_NAME /profile
6+
47
#
58
# Install profiling tools
69
#
@@ -46,7 +49,6 @@ RUN apt-get update && \
4649
libtalloc2-dbgsym \
4750
libpcre2-8-0-dbgsym \
4851
libpcap0.8t64-dbgsym \
49-
libcurl4t64-dbgsym \
5052
libunbound8-dbgsym \
5153
libsqlite3-0-dbgsym \
5254
libpq5-dbgsym \
@@ -57,6 +59,7 @@ RUN apt-get update && \
5759
libhiredis1.1.0-dbgsym \
5860
librdkafka1-dbgsym \
5961
libwbclient0-dbgsym && \
62+
(apt-get install -y $APT_OPTS libcurl4t64-dbgsym || true) && \
6063
apt-get clean && \
6164
rm -r /var/lib/apt/lists/*
6265

scripts/docker/profiling/profiles/default-profiling/README

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Default Profiling Profile
2+
3+
Default profiling profile for FreeRADIUS, using Valgrind. The scripts in this directory are copied into the profiling Docker image at build time.
4+
5+
## Scripts
6+
7+
| Script | Description |
8+
|----------------|----------------------------------------------------------------|
9+
| `configure.sh` | Configures the FreeRADIUS build with profiling options enabled |
10+
| `start.sh` | Starts the profiling session |
11+
12+
## Building the image
13+
14+
The profiling image is built on top of a crossbuild image using the make targets defined in
15+
[scripts/docker/crossbuild.mk](../../../../../crossbuild.mk). The `Dockerfile.prof` is generated
16+
from the m4 template at [scripts/docker/m4/profiling.deb.m4](../../../../m4/profiling.deb.m4).
17+
18+
```sh
19+
# Regenerate Dockerfile.prof (if the m4 template changed)
20+
make crossbuild.IMAGE.profile.regen
21+
22+
# Build the profiling image
23+
make crossbuild.IMAGE.profile.build
24+
```
25+
26+
Replace `IMAGE` with the target OS, e.g. `ubuntu24`. This profile is used by default
27+
(`PROFILE=default-profiling`). To use a different profile:
28+
29+
```sh
30+
make crossbuild.IMAGE.profile.build PROFILE=<name>
31+
```
32+
33+
## Usage
34+
35+
Once inside the container:
36+
37+
```sh
38+
# Configure the FreeRADIUS build
39+
./configure.sh
40+
41+
# Start profiling
42+
./start.sh
43+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# CFLAGS used for profiling build:
5+
# -g3 Maximum debug info for callgrind symbol resolution
6+
# -O1 Basic optimisation for realistic hotspot costs; inlining/vectorisation/
7+
# unrolling disabled below so the call graph matches the source.
8+
# -fno-omit-frame-pointer Keep frame pointers for callgrind stack walking
9+
# -fno-inline Preserve call edges (suppresses CC_HINT(flatten) too)
10+
# -Dalways_inline= Strip always_inline, which -fno-inline does not suppress
11+
# -fno-plt Resolve cross-library calls via GOT rather than PLT stubs;
12+
# PLT stubs have no DWARF info and show as ??? in callgrind.
13+
# -fno-builtin Keep stdlib calls (memcpy, strlen, etc.) visible in the graph
14+
# -fno-optimize-sibling-calls Suppress tail-call elimination (-O1 can still apply it)
15+
./configure \
16+
--enable-developer \
17+
--disable-verify-ptr \
18+
--with-raddbdir=/etc/freeradius \
19+
CFLAGS="-g3 -O1 -fno-omit-frame-pointer -fno-inline -Dalways_inline= -fno-plt -fno-builtin -fno-optimize-sibling-calls" \
20+
LDFLAGS="-fno-omit-frame-pointer"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
valgrind \
5+
--tool=callgrind \
6+
--callgrind-out-file=/profile/results/callgrind.out.%p \
7+
--trace-children=yes \
8+
--separate-threads=yes \
9+
--dump-instr=yes \
10+
--collect-jumps=yes \
11+
--cache-sim=yes \
12+
--branch-sim=yes \
13+
--keep-debuginfo=yes \
14+
--instr-atstart=yes \
15+
freeradius -f -l stdout -S resources.talloc_skip_cleanup=yes

0 commit comments

Comments
 (0)