Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/heimdall

docs/bench/postgres-filter/README.md

PostgreSQL under pgbench: no filter and Heimdall's static filter

Lane bench-pg, 2026-11-09. A real container workload, the official PostgreSQL 17.11 image under pgbench, with the server container unfiltered (none) and under Heimdall's static filter (static): a floor that heimdall profile gen generated from LOG runs of this workload, compiled by Heimdall's own builder inside youki. The graph filter's row is pending: the harness refuses --mode graph and writes no number for it.

The harness is dwarves' ci-verbs bench-filter (ci/verbs/src/bench_filter.rs). Every number below comes from the receipts beside this file: results/<host>-<date>/receipts/*.json, one per run, and summary.json / summary.md, written by ci-verbs bench-filter --summarize.

One host, one workload, static filter only. Two hosts were used, one after the other, and their numbers are not mixed: the floor, the LOG runs and the first pairs were made on oden; oden was then taken away, and the bench was repeated in full on build-1, a different and busier host.

Result: build-1, 15 pairs (2026-11-09)

build-1: a VM with 16 vCPUs of an AMD EPYC 9575F, Ubuntu 24.04.5, kernel 6.8.0-147-generic, rootful podman 4.9.3, shared with other lanes. The server on vCPUs 4-11, the client on vCPUs 12-15, nice 10. Load average (1 min) 48 to 99 during the runs. This host is not oden: the numbers below are build-1's only (results/build-1-2026-11-09).

phase metric none (median) static (median) static vs none: median of the pairs range
read-write TPS 2032.1 2044.3 -0.21 % -54.11 % to +210.66 %
read-write latency average (ms) 7.874 7.827 +0.21 % -67.81 % to +117.91 %
read-write p50 (ms) 6.592 6.789 +3.78 % -79.76 % to +119.40 %
read-write p99 (ms) 27.583 25.053 +13.20 % -55.33 % to +94.39 %
read-write server CPU per transaction (µs) 282.7 286.2 +1.09 % -31.37 % to +52.82 %
read-write of it in the kernel (µs) 94.7 94.3 +1.82 % -24.20 % to +25.41 %
read-only TPS 19603.7 19927.5 -10.46 % -58.88 % to +98.71 %
read-only latency average (ms) 0.816 0.803 +11.71 % -49.68 % to +143.04 %
read-only p50 (ms) 0.166 0.165 +0.68 % -40.27 % to +59.85 %
read-only p99 (ms) 7.776 7.907 +8.89 % -42.49 % to +98.19 %
read-only server CPU per transaction (µs) 39.4 39.9 +1.76 % -28.15 % to +35.48 %
read-only of it in the kernel (µs) 15.2 15.6 +0.91 % -22.65 % to +27.36 %

System calls of the server's cgroup, from one count run per mode after the pairs (perf stat -e raw_syscalls:sys_enter, not timed, not paired): 41 per read-write transaction and 7.4 per read-only transaction, in both modes (none 41.1 and 7.40, static 40.9 and 7.39), the same as on oden.

0 kills in all 32 runs (30 timed, 2 counted): every static run's server had Seccomp: 2 with 1 filter, every none run's Seccomp: 0.

What the numbers say

Earlier results on oden (partial, not mixed with build-1)

oden: AMD Ryzen Threadripper PRO 3975WX (32 cores, no SMT), Ubuntu 26.04.1, kernel 7.0.0-42-generic, rootless podman 5.7.0, server on CPUs 16-27 (three L3 groups), client on CPUs 28-31, nice 10, load average 34 to 59 during the runs (other lanes compiled at nice 0 on every CPU).

5 pairs with the CPU metric (harness dwarves 3175de2), stopped when oden was taken away; fewer than the 9 pairs a published number needs, so read it as a first look only (results/oden-2026-11-09-partial):

phase metric none (median) static (median) static vs none: median of the 5 pairs range
read-write TPS 25063.6 21540.8 -16.65 % -39.08 % to +103.34 %
read-write p99 (ms) 2.109 2.468 +40.52 % -58.61 % to +71.57 %
read-write server CPU per transaction (µs) 251.1 254.4 -0.31 % -2.79 % to +3.43 %
read-write of it in the kernel (µs) 63.6 66.2 +4.08 % -1.08 % to +4.42 %
read-only TPS 144744.0 139717.4 +7.31 % -3.47 % to +36.35 %
read-only p99 (ms) 0.394 0.354 -14.98 % -55.34 % to +22.61 %
read-only server CPU per transaction (µs) 40.3 40.1 -0.77 % -4.51 % to +4.21 %
read-only of it in the kernel (µs) 11.0 11.4 +0.08 % -1.39 % to +3.55 %

In 4 of these 5 pairs static's kernel CPU per read-write transaction was +3.9 to +4.4 % (about +2.6 µs per transaction, some 60 ns per call), more than the ~20 ns per call measured below; read-only showed nothing of the kind. build-1's 15 pairs do not show it (+1.8 %, -24 to +25 %). With 5 pairs on a busy host this is an open question, not a finding: a quiet host would answer it.

Before that, 7 pairs of the first harness version (dwarves 9e069bc, TPS and latency only, no CPU metric) were stopped to add the CPU metric, because one run's TPS moved by tens of percent with the host's other work (results/oden-2026-11-09-aborted-v1; its receipts predate the CPU fields, so --summarize of today's harness refuses them). Over its 6 complete pairs static's read-write TPS was -34 % (median), ranging from -44 % to +44 %: the same spread.

A check outside the harness, on oden in the same containers: dd with 1-byte blocks (10 M read and write calls) took 1.64 and 1.66 s unfiltered and 1.82 and 1.85 s under the floor, +18 to +19 ns per call, the cost bench/floor-cost measured for a call the kernel answers from its action cache.

Limits

Method

Workload

Containers

Pinning

build-1: the server on vCPUs 4-11, the client on vCPUs 12-15 (12 of 16 in all). oden: the server on CPUs 16-27 (three whole L3 groups of 4 cores), the client on CPUs 28-31 (one L3 group). Both through taskset and nice -n 10, inherited by conmon and the container. Every run reads the server's Cpus_allowed_list and nice value from /proc and refuses a run whose pinning did not hold.

Pairs

15 pairs. Pair p runs none then static when p is even, static then none when it is odd. The summary takes, per pair, static's value against none's (in %), and reports the median of the 15 with its range (min to max), as bench/floor-cost reports its rows. Kills are counted per run from the kernel log (audit type 1326 with sig=31 naming one of the image's programs) and from the server's log (terminated by signal 31); a run with a kill gives no number.

The floor: from LOG runs only

The floor was made by tools from evidence, never by hand:

  1. LOG runs (scripts/logrun.sh): the server container under a profile whose default is SCMP_ACT_LOG (scripts/log.json; clone3 answered ENOSYS as the floor answers it), with youki's libseccomp backend (the same binary, named youki), and heimdall profile probe-log as the kernel's audit daemon, started before the container. Each run covers the container's whole life: initdb and the entrypoint's temporary server, the start, pgbench -i -s 50, read-write, read-only, CHECKPOINT, VACUUM ANALYZE, read-write again (autovacuum ran on three tables), and the shutdown (fast shutdown, with its checkpoint). The client was unfiltered, so only the server container's calls were logged.
run pgbench audit records distinct calls records lost
log1 rate-limited (-R 1500 read-write, -R 4000 read-only), 120 s per phase 19,419,363 110 0
log2 full speed, 60 s per phase 28,610,612 110 128,053,994

log1 lost no record. The reviews print the kernel's lost counter, which counts since the host booted: it read 621,238 after an earlier smoke run and still 621,238 after log1, and 128,675,232 after log2. log2 lost records at full speed, and saw exactly the same 110 calls as log1.

  1. Merge and generate (scripts/genfloor.sh): heimdall profile merge of the two evidence files into floor/postgres-pgbench/x86_64-glibc.probe.json, then heimdall profile gen postgres-pgbench --libc glibc --allow-marked. The floor was made from runs with lost records: both end lines say stopped INCOMPLETE (log2 lost records at full speed; log1's line carries the kernel counter's 621,238 from before it started), so gen names both as marked runs and makes the profile only with --allow-marked, which the script passes on purpose. The result: 113 rules, 112 calls allowed (the 110 seen, plus exit and restart_syscall of the base set), clone3 answered ENOSYS, default KILL_PROCESS, 0 near-miss, 0 W|X left out; mmap and mprotect keep their W|X rule, every other call is a bare allow. The floor is floor/postgres-pgbench/x86_64-glibc.oci.json, sha256 34d0b9422e8e59567cec872a8073563e18da3f2b3bf68acf8e501711ea8518a2. Generating it again from the evidence gives the same bytes.

  2. Who made the calls: postgres itself 81 of the 110; the other 29 only by the entrypoint's tools and the runtime (gosu: setuid, setgid, setgroups and the Go runtime's calls; bash, dash, find, chmod, chown, ls, psql; youki's init after the filter is installed: sendmsg, accept4, statx). One filter covers the whole container, because seccomp is inherited across exec.

  3. 0 kills under enforce before measuring (scripts/enfrun.sh): the same lifecycle as the LOG runs at full speed, with the server enforced under the floor by youki-heimdall, once on each host: enf1 on oden (kernel 7.0) and b1-enf1 on build-1 (kernel 6.8, before its pairs). Both: server exit 0, Seccomp: 2 with 1 filter, 0 kill records in the kernel log, 0 failed transactions. Every timed run checks again: 0 kills in all 32 build-1 runs and in all of oden's.

The floor was made on oden and used unchanged on build-1. Files: log-runs/log1, log-runs/log2 (the evidence, the probe-log review, the client's and the server's logs), enforce-check/enf1 (oden), enforce-check/b1-enf1 (build-1), floor/postgres-pgbench.

Reproduce

On a Linux host with podman (rootless, with sudo for the audit daemon, dmesg and perf; or as root), cgroup v2 and taskset. The scripts expect the lane layout $L/{heimdall,dwarves,edda,youki,bin,floor,runs,results} (L defaults to ~/lanes/bench-pg; build-1 used L=/work3/bench-pg).

# Heimdall's CLI (heimdall main dab750ca), static musl, in the toolchain container
cargo build --release --locked -p nordisk-heimdall-cli --target x86_64-unknown-linux-musl
# youki-heimdall: Ignalina/youki feat/seccomp-backend-trait 5aeca235 + scripts/youki-heimdall.patch
cargo build --release -p youki --no-default-features --features systemd,v2,seccomp
cp target/release/youki bin/youki-heimdall; cp target/release/youki bin/youki
# the bench verb: dwarves main, ci/verbs (edda beside dwarves)
cargo build --release --manifest-path dwarves/ci/verbs/Cargo.toml
# LOG runs, the floor, the enforce check
scripts/logrun.sh log1                       # LOGARGS="throttled 50 16 4 120"
LOGARGS="full 50 16 4 60" scripts/logrun.sh log2
scripts/genfloor.sh runs/log1/evidence.json runs/log2/evidence.json
scripts/enfrun.sh enf1
# the bench: build-1, as root
L=/work3/bench-pg WORK=/dev/shm/bench-filter SCPU=4-11 CCPU=12-15 PAIRS=15 \
  scripts/bench.sh /work3/bench-pg/results/2026-11-09-build-1

scripts/bench.sh is this line:

ci-verbs bench-filter --workload postgres-pgbench --mode none,static --runs 15 \
  --out <dir> --work /dev/shm/bench-filter \
  --image docker.io/library/postgres@sha256:996e9dc583ba9f0265a2c75547a9c95fb22c251e394749cab205a0a00e1856a1 \
  --runtime bin/youki-heimdall --floor floor/postgres-pgbench/x86_64-glibc.oci.json \
  --heimdall bin/heimdall --heimdall-commit dab750ca0e7e53d84efcf9a39c5d3572438b576a \
  --server-cpus 4-11 --client-cpus 12-15 --nice 10 \
  --scale 50 --clients 16 --threads 4 --seconds 60 --warmup 15 --sampling-rate 0.05 \
  --kernel-log dmesg --count-syscalls perf

(As a rootless user: --kernel-log "sudo -n dmesg" --count-syscalls "sudo -n perf".)

ci-verbs bench-filter --summarize <dir> rewrites summary.json and summary.md from the receipts alone.

The graph row

The 2026-11-10 graph-input checkpoint records the pinned server's C capture, binary scan, real server-only call pairs, order graphs and Heimdall check outputs. The latest source graph retains 65,232 unresolved sites; both source-only and binary-assisted checks refuse import before pair coverage. Source/native binding and dynamic-image admission are also open. Graph construction timing is recorded separately and is not a PostgreSQL filter-performance result.

The harness takes the mode as a parameter. --mode graph is refused before anything runs, and no number is written:

$ ci-verbs bench-filter --workload postgres-pgbench --mode none,static,graph --runs 15 ...
bench-filter: graph mode needs a complete graph of the workload; not wired yet
(exit 2)

The graph row needs a complete graph of this workload (postgres, the entrypoint's tools, gosu and youki's init) and the follower attached to the server's container. When that exists, the places to wire in dwarves ci/verbs/src/bench_filter.rs are refuse_unwired, the Mode::Graph arm of server_command (the floor, plus the follower attached on the server container's cgroup), and validate (a graph receipt must name the graph digest and the follower's violation count). The same command with --mode none,static,graph then gives the third column, paired against the same none runs.