mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
19 hours ago b9d727d8e6094a7aa4356a1c9f310c6363d220e9
ci: add "Benchmark PDB vs JE" step to build-docker (#718)
2 files modified
44 ■■■■ changed files
.github/benchmark/compare-opendj.sh 25 ●●●● patch | view | raw | blame | history
.github/workflows/build.yml 19 ●●●●● patch | view | raw | blame | history
.github/benchmark/compare-opendj.sh
@@ -20,6 +20,8 @@
# Usage:
#   compare-opendj.sh <A_name> <A_image> <B_name> <B_image>
# Env: THREADS (default 200), DURATION (default 150), JMETER_VERSION (default 5.6.3).
#      A_BACKEND / B_BACKEND (optional) -- userRoot backend type per side (e.g. je, pdb);
#      when set, passed to the container as -e BACKEND_TYPE=<type>. Empty => image default.
set -euo pipefail
A_NAME="${1:?server A name required}"
@@ -30,6 +32,8 @@
THREADS="${THREADS:-200}"
DURATION="${DURATION:-150}"
JMETER_VERSION="${JMETER_VERSION:-5.6.3}"
A_BACKEND="${A_BACKEND:-}"
B_BACKEND="${B_BACKEND:-}"
BASEDN="dc=example,dc=com"
BENCHPW="benchPass1"
HERE="$(cd "$(dirname "$0")" && pwd)"   # .github/benchmark
@@ -55,12 +59,15 @@
  return 1
}
# bench_one <image> <out-slug>  -> prints the captured server version (stdout only)
# bench_one <image> <out-slug> [backend-type]  -> prints the captured server version (stdout only)
bench_one() {
  local image="$1" out="$2" ver=""
  local image="$1" out="$2" backend="${3:-}" ver=""
  docker rm -f opendj-bench >/dev/null 2>&1 || true
  # ${backend:+...} expands to "-e BACKEND_TYPE=<type>" only when a type is given; the
  # values used (je/pdb) contain no spaces, so word-splitting is safe and portable.
  if docker run -d --name opendj-bench -p 1389:1389 \
       -e ROOT_PASSWORD=password -e BASE_DN="$BASEDN" -e ADD_BASE_ENTRY=--addBaseEntry \
       ${backend:+-e BACKEND_TYPE=$backend} \
       "$image" >/dev/null 2>&1; then
    wait_dj || echo "WARN: $image not ready in time" >&2
    ldapadd -x -H ldap://localhost:1389 -D "cn=Directory Manager" -w password \
@@ -91,10 +98,10 @@
  printf '%s' "$ver"
}
echo "Benchmarking ${A_NAME} (${A_IMAGE}) @ ${THREADS} threads / ${DURATION}s ..."
A_VER="$(bench_one "$A_IMAGE" a)"
echo "Benchmarking ${B_NAME} (${B_IMAGE}) @ ${THREADS} threads / ${DURATION}s ..."
B_VER="$(bench_one "$B_IMAGE" b)"
echo "Benchmarking ${A_NAME} (${A_IMAGE}${A_BACKEND:+, backend=$A_BACKEND}) @ ${THREADS} threads / ${DURATION}s ..."
A_VER="$(bench_one "$A_IMAGE" a "$A_BACKEND")"
echo "Benchmarking ${B_NAME} (${B_IMAGE}${B_BACKEND:+, backend=$B_BACKEND}) @ ${THREADS} threads / ${DURATION}s ..."
B_VER="$(bench_one "$B_IMAGE" b "$B_BACKEND")"
{
  bash "$HERE/summary.sh" \
@@ -103,8 +110,14 @@
  echo ""
  echo "### Notes"
  echo ""
  if [ -n "${A_BACKEND}${B_BACKEND}" ]; then
    echo "- **${A_NAME}** (\`BACKEND_TYPE=${A_BACKEND:-default}\`) and **${B_NAME}**"
    echo "  (\`BACKEND_TYPE=${B_BACKEND:-default}\`) are the same OpenDJ image; only the userRoot"
    echo "  backend type differs, so the comparison isolates the storage backend."
  else
  echo "- **${A_NAME}** = freshly built image; **${B_NAME}** = latest released image. Both are"
  echo "  OpenDJ, so they share the same default password storage scheme (hashing parity is automatic)."
  fi
  echo "- The admin connection bind (\`ADMIN_CONNECT\`) is cached per thread and excluded; \`BIND\` is"
  echo "  the measured user authentication (\`test=sbind\`, single bind/unbind)."
} >> "${GITHUB_STEP_SUMMARY:-/dev/stdout}"
.github/workflows/build.yml
@@ -442,6 +442,25 @@
        with:
          path: ~/jmeter
          key: jmeter-5.6.3
      - name: Benchmark PDB vs JE
        shell: bash
        run: |
          A_BACKEND=je B_BACKEND=pdb THREADS=200 DURATION=150 bash .github/benchmark/compare-opendj.sh \
            "JE"  localhost:5000/${GITHUB_REPOSITORY,,}:${{ env.release_version }} \
            "PDB" localhost:5000/${GITHUB_REPOSITORY,,}:${{ env.release_version }}
      - name: Upload benchmark artifacts (PDB vs JE)
        if: always()
        uses: actions/upload-artifact@v7
        with:
          name: benchmark-pdb-vs-je
          path: |
            a/
            b/
            *.jtl
            *.docker.log
            *.jmeter.out
          if-no-files-found: warn
          retention-days: 3
      - name: Benchmark Build vs Release
        shell: bash
        run: |