Repository navigation
feat(benchmark): M2–M4 — S3–S6 scenarios + config.bench.json + first data drop - #48
Conversation
Implements the remaining 4 benchmark scenarios on top of the M1 harness: - S3 introspect (active-token RS256 verify, reusable AT pool) - S4 auth_code+PKCE (multi-step login→token, per-VU user rotation, -t==-c) - S5 refresh_token (V008 one-shot RT pool, --reseed per level) - S6 userinfo (bearer user AT, reusable pool) New infrastructure: - lib/gen-tokens.py: generates raw tokens + SHA256 hashes + PKCE pairs - observe/docker-stats.sh + observe/scrape-metrics.sh: M3 resource observation - measure-cold-start.sh: cold-start time + RSS peak measurement - run-scenario.sh: --reseed, --observe flags; WRK_LIB_DIR/WRK_NTHREADS export - setup.sh: auto token pool generation + warmup_bench_users invocation Token hashing matches TokenCrypto::hashToken (TokenCrypto.cc:26-37). All Lua scripts syntax-verified (lupa loadfile); bash -n on all shell scripts. Part of C1 (benchmark M2-M3, next-phase-implementation-plan.md).
…olution The --reseed path used 'docker compose ps -q oauth2-postgres' to find the postgres container, but this fails when the compose project name or args don't match what setup.sh used to boot the stack. Use 'docker ps --filter name=oauth2-postgres' instead — more reliable and project-name-independent. Found during live WSL validation: S5 refresh_token showed 'reseed WARN: postgres container not found' + 100% error rate because the TRUNCATE+INSERT never ran (pool was depleted by warmup). After fix: reseed OK, 0% errors.
Benchmark-specific config + first data drop + load-bearing verification: - config.bench.json: PG=25, Redis=20, log_level=WARN (dev/prod untouched) - setup.sh auto-swaps config.bench.json → config.json (backup + teardown restore) - 40 result JSONs (S1-S6 × c=2..128) from WSL 8vCPU/16GB run - SUMMARY.md: 6-scenario staircase + load-bearing verification (AC3+AC7) - S1 discovery 86k QPS (⚠️ near 100k target) - S2 client_credentials 8.9k QPS (P99 8ms) - S3 introspect 17k QPS (P99 12ms) - S4 auth_code 465 QPS (PBKDF2 bottleneck, P99 159ms) - S5 refresh_token 2k QPS (P99 26ms) - S6 userinfo 17k QPS (P99 12ms) - P99 <2ms ✅ at low concurrency; memory ❌ needs redefinition; cold-start ⏳ pending Config swap approach replaces compose volume override (Docker Desktop bind-mount cache issue). Verified end-to-end on WSL.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 292ca37740
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "INSERT INTO oauth2_access_tokens\n", | ||
| " (token, client_id, user_id, scope, expires_at, revoked,\n", | ||
| " issued_at, issuer, not_before, introspect_count)\n", | ||
| "SELECT td.token_hash, 'backend-svc', bu.id::text, 'openid profile',\n", |
There was a problem hiding this comment.
Seed userinfo tokens with public subjects
When S6 uses the generated access-token pool, this stores users.id in oauth2_access_tokens.user_id, but the real login path puts the user's publicSub into the authorization code and token, and OAuth2Plugin::getUserInfo routes numeric subjects through findById instead of the public-sub lookup used by real bearer tokens. As a result, S6 can report a green userinfo benchmark while exercising a different subject shape and lookup path than production auth-code tokens; seed bu.public_sub::text for these user access tokens instead.
Useful? React with 👍 / 👎.
| if [ -f "$REPO_ROOT/deploy/docker/docker-compose.bench.yml" ]; then | ||
| export BENCH_TARGET_CONFIG="${BENCH_TARGET_CONFIG:-config.bench.json}" |
There was a problem hiding this comment.
Record the swapped benchmark config
This detection looks for deploy/docker/docker-compose.bench.yml, but this commit does not add that file, and the BENCH_TARGET_CONFIG exported by setup.sh is lost when run-scenario.sh is invoked later as a separate process. I checked the committed result JSONs and all 40 still say env.target_config is config.json even though the report claims config.bench.json, so future benchmark data will be mislabeled unless this script detects the config swap or receives a persisted flag.
Useful? React with 👍 / 👎.
| bash "$BENCH_DIR/observe/docker-stats.sh" "$STATS_FILE" "${DURATION_S}s" & | ||
| STATS_PID=$! | ||
| bash "$BENCH_DIR/observe/scrape-metrics.sh" "$TARGET_URL" "$METRICS_FILE" "${DURATION_S}s" & | ||
| METRICS_PID=$! |
There was a problem hiding this comment.
With --observe, both collectors are started here before the discarded warmup but are given only DURATION_S as their timeout. Under the defaults (WARMUP_S=10, DURATION_S=30) the observation files cover the warmup plus only the first ~20 seconds of the measured run, missing the tail where RSS/metrics can peak; if warmup is at least the duration, they can miss the measured run entirely. Start the observers after warmup and the pre-measure reseed, or extend/segment the collection window so it actually covers the measured run.
Useful? React with 👍 / 👎.
Address Codex review feedback on PR #48: 1. target_config mislabeling: run-scenario.sh detected a deleted file (docker-compose.bench.yml) to set BENCH_TARGET_CONFIG. Changed to detect config.json.dev-backup (the actual swap marker). Verified: new result JSONs correctly show env.target_config=config.bench.json. 2. observer timing: --observe collectors were started before warmup, so their DURATION_S timeout covered warmup + only part of the measured run. Moved observer startup to AFTER warmup + reseed, immediately before the measured wrk run. Now the collection window exactly covers the measured run. Note on review comment #1 (S6 subject format): verified NOT an issue — real login tokens store numeric users.id (SessionController.cc:505), same as the benchmark seed. Both hit the findById code path. No change needed.
CHANGELOG for v1.2.0 (61 commits since v1.1.0): #43 resource-scope authorization model, A2 user-management CRUD (PR #52), B1 back-channel logout backend (PR #50), A1 OpenAPI spec governance M0 + breaking-change gates (PR #63), benchmark M2-M4 load-bearing verdicts (PR #48), and the #53-#60 user-admin hardening batch (PR #62). Per the release SOP (docs/backend/versioning-and-release.md §11.1): draft via `git cliff --unreleased --tag v1.2.0 --prepend`, then hand-curated (themed sections, security-hardening migrations, noise removed). Version SSoT already bumped to 1.2.0 in e5548ec; api-diff and the new spec-governance gate verified OK on the release ref.
Summary
Implements benchmark facility milestones M2–M4 on top of the M1 harness (S1/S2), completing Phase 0 scenario coverage and producing the first load-bearing verification report.
What's included
M2–M3: Scenarios S3–S6 + infrastructure (
eda89da)POST /oauth2/introspectPOST /oauth2/login→POST /oauth2/token-t == -cPOST /oauth2/token(refresh)--reseedper levelGET /oauth2/userinfoNew files:
lib/gen-tokens.py— generates raw tokens +UPPER(SHA256(raw))hashes (matchesTokenCrypto.cc:26-37) + S256 PKCE pairsobserve/docker-stats.sh+observe/scrape-metrics.sh— M3 resource observation (--observeflag)measure-cold-start.sh— cold-start time + RSS peakrun-scenario.sh—--reseed,--observe,WRK_LIB_DIR/WRK_NTHREADSexport, S4-t==-cauto-overridesetup.sh— auto token pool generation +warmup_bench_users(PBKDF2 rehash)Bug fix (
6a9e4a4):--reseedcontainer resolution changed fromdocker compose ps→docker ps --filter(compose project name mismatch).M4: Config + data + report (
292ca37)config.bench.json— benchmark-specific config (PG=25, Redis=20, log=WARN). Dev/prod configs untouched. Auto-swapped bysetup.sh, restored byteardown.sh.benchmarks/results/)SUMMARY.md— one-page summary + load-bearing verification report (AC3+AC7):Live-verified results (WSL2 8vCPU/16GB, wrk 4.1.0)
Config swap mechanism
Docker Desktop WSL2 has a bind-mount cache issue with compose volume overrides. The final approach is a file swap:
setup.sh: backs upconfig.json→config.json.dev-backup, copiesconfig.bench.json→config.jsonteardown.sh: restores from backup, cleans upOut of scope
gen-summary.pyauto-generator (hand-written SUMMARY.md for now)productization-research.md §3.1revision (defer until competitor comparison)measure-cold-start.shrun)Test plan
bash -nsyntax check on all shell scriptsgen-tokens.pydry-run: SQL structure correct, hash matchesTokenCrypto.cc, PKCE pairs valid S256Ref: next-phase-implementation-plan.md C1, benchmark-facility-design.md M2–M4