From 57f54a71d0fb031279fcf011e86680308d9b8cb1 Mon Sep 17 00:00:00 2001 From: yellowhat <1692490+yellowhat@users.noreply.github.com> Date: Wed, 11 Nov 2026 15:19:45 +0100 Subject: [PATCH] Add benchmark against a stub --- bench/.gitignore | 2 + bench/00_dnspyre_blocky.sh | 22 ++++++ .../01_dnspyre_upstream.sh | 3 +- bench/pod.yaml | 72 +++++++++++++++++++ justfile | 18 +++++ renovate.json | 5 +- 6 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 bench/.gitignore create mode 100644 bench/00_dnspyre_blocky.sh rename scripts/benchmark.sh => bench/01_dnspyre_upstream.sh (96%) create mode 100644 bench/pod.yaml diff --git a/bench/.gitignore b/bench/.gitignore new file mode 100644 index 00000000..2385b03e --- /dev/null +++ b/bench/.gitignore @@ -0,0 +1,2 @@ +data/ +results/ diff --git a/bench/00_dnspyre_blocky.sh b/bench/00_dnspyre_blocky.sh new file mode 100644 index 00000000..7cb3ec5a --- /dev/null +++ b/bench/00_dnspyre_blocky.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# Benchmark blocky (pod published UDP port, see pod.yaml) +set -euo pipefail + +# renovate: datasource=docker depName=ghcr.io/tantalor93/dnspyre +DNSPYRE_VER=v3.12.0 + +args=( + # getent hosts host.containers.internal + --server "169.254.1.2:8053" + --concurrency 1 + --duration 60s + --no-distribution + --probability 0.33 + https://raw.githubusercontent.com/Tantalor93/dnspyre/master/data/10000-domains +) +podman run \ + --name dnspyre \ + --interactive \ + --tty \ + --rm \ + "ghcr.io/tantalor93/dnspyre:$DNSPYRE_VER" "${args[@]}" diff --git a/scripts/benchmark.sh b/bench/01_dnspyre_upstream.sh similarity index 96% rename from scripts/benchmark.sh rename to bench/01_dnspyre_upstream.sh index 38855fc5..f3105e15 100644 --- a/scripts/benchmark.sh +++ b/bench/01_dnspyre_upstream.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Benchmark providers +# Benchmark upstream providers set -euo pipefail # renovate: datasource=docker depName=ghcr.io/tantalor93/dnspyre @@ -24,7 +24,6 @@ for provider in "${providers[@]}"; do --probability 0.33 https://raw.githubusercontent.com/Tantalor93/dnspyre/master/data/1000-domains ) - podman run \ --name dnspyre \ --interactive \ diff --git a/bench/pod.yaml b/bench/pod.yaml new file mode 100644 index 00000000..225d9aa6 --- /dev/null +++ b/bench/pod.yaml @@ -0,0 +1,72 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + name: blocky-bench +spec: + initContainers: + - name: config + image: docker.io/mikefarah/yq:4.54.3 + securityContext: + runAsUser: 0 + command: [sh, -c] + args: + - | + yq ' + .upstreams.groups.default = ["127.0.0.1:5301"] + | del(.bootstrapDns) + | del(.blocking) + | del(.dnssec) + | del(.caching) + | .queryLog.type = "none" + ' /in/config.yaml > /out/config.yml + volumeMounts: + - name: in-config + mountPath: /in/config.yaml + readOnly: true + - name: config + mountPath: /out + containers: + - name: blocky + image: ghcr.io/0xerr0r/blocky:v0.36.0 + env: + - name: GOMAXPROCS + value: "2" + - name: BLOCKY_CONFIG_FILE + value: /config/config.yml + ports: + - name: dns + containerPort: 5353 + hostPort: 8053 + protocol: UDP + resources: + limits: + cpu: "2" + volumeMounts: + - name: config + mountPath: /config + readOnly: true + # Stub upstream: answers every A query with 10.0.0.1, TTL 1h (so blocky can cache) + - name: stub + image: docker.io/library/alpine:latest + command: [ash, -c] + args: + - | + apk add dnsmasq + exec dnsmasq \ + --keep-in-foreground \ + --listen-address=127.0.0.1 \ + --port=5301 \ + --no-resolv \ + --no-hosts \ + --bind-interfaces \ + --cache-size=0 \ + --local-ttl=3600 \ + --address=/#/10.0.0.1 + volumes: + - name: in-config + hostPath: + path: ../config.yaml + type: File + - name: config + emptyDir: {} diff --git a/justfile b/justfile index 6032d4c1..03ed7ea7 100644 --- a/justfile +++ b/justfile @@ -39,3 +39,21 @@ clean: **/.pytest_cache \ **/.pytype \ **/.mypy_cache + +# Start environment to benchmark +[group("benchmark")] +[working-directory: "./bench"] +bench-env: + podman kube play pod.yaml --replace + +# Start benchmark +[group("benchmark")] +[working-directory: "./bench"] +bench-run: + bash 00_dnspyre_blocky.sh + +# Stop pod used for benchmark +[group("benchmark")] +[working-directory: "./bench"] +bench-stop: + podman kube down pod.yaml diff --git a/renovate.json b/renovate.json index 7190a60b..1c351ced 100644 --- a/renovate.json +++ b/renovate.json @@ -1,3 +1,6 @@ { - "$schema": "https://docs.renovatebot.com/renovate-schema.json" + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "kubernetes": { + "managerFilePatterns": ["/^bench/pod\\.yaml$/"] + } }