Skip to content

feat: add Go benchmarks for reconciliation hot paths#2035

Draft
maksymvavilov wants to merge 6 commits into
Kuadrant:mainfrom
maksymvavilov:pref-testing
Draft

feat: add Go benchmarks for reconciliation hot paths#2035
maksymvavilov wants to merge 6 commits into
Kuadrant:mainfrom
maksymvavilov:pref-testing

Conversation

@maksymvavilov

@maksymvavilov maksymvavilov commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Go benchmarks for reconciliation hot paths with a CI workflow that posts benchstat comparisons on PRs. 11 benchmark functions, 40 sub-benchmarks, ~10.7 min total runtime.

Benchmarks

All benchmarks use the bench build tag (//go:build bench), fully decoupled from unit tests.

Benchmark What it measures Sub-benchmarks
CalculateEffectiveAuthPolicies O(GC×RouteRules) Paths() loop 10, 100, 300 routes; 3gc×100
EffectiveRateLimitPolicies RLP effective policy calculation 10, 100, 300 routes
EffectiveAuthPoliciesListenerFanout Listener scaling impact on Paths() DFS 1, 4, 16, 32 listeners
EffectiveAuthPoliciesMultiGateway Multi-gateway with distributed routes 3gc, 10gc
TopologyToDot DAG-to-DOT serialization (called every cycle) 10, 100, 300, 1000 objects
BuildDesiredAuthConfig AuthConfig generation per route rule 1, 10, 100, 300 rules
BuildLimitadorLimits Merging effective policies into Limitador limits 10, 100, 300 policies
TopologyPaths Isolated Paths() DFS traversal narrow, wide, deep, stress
GetKuadrantFromTopology Kuadrant CR lookup cost (~28 calls/cycle) 10, 100, 300 routes
TopologyBuild Cost of constructing the topology 10–300 routes; 32L, 3gc×16L
FullReconciliationCycle Topology build + lookups + all 3 reconcilers 10, 100, 300 routes

Running

# Full suite (10 repetitions for benchstat)
make test-bench

# Single benchmark
go test ./internal/controller/... -bench=BenchmarkTopologyPaths -benchmem -run='^$' -count=1 -tags bench

# Compare before/after with benchstat
benchstat before.txt after.txt

CI Workflow

.github/workflows/benchmark.yaml runs on PRs touching internal/, pkg/, api/, go.mod:

  • Runs benchmarks on both PR and base branch (-count=10)
  • Posts benchstat comparison as a sticky PR comment
  • Inform-only — does not fail the build
  • Uploads raw results as artifacts

Credits

Scaling benchmarks (listener fanout, multi-gateway, RLP, topology build, full cycle) adapted from Mike Nairn's PR #2031.

🤖 Generated with Claude Code

maksymvavilov and others added 2 commits May 28, 2026 09:44
Signed-off-by: Maskym Vavilov <mvavilov@redhat.com>
Add benchmark functions for the 5 identified hot paths: effective policy
calculation, topology ToDot serialization, AuthConfig building, Limitador
limits building, and topology Paths() traversal. Includes a Makefile
test-bench target and a GitHub Actions workflow that posts benchstat
comparisons as PR comments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Maskym Vavilov <mvavilov@redhat.com>
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1086cdc9-5e9d-4df7-8dcd-d41bda2f19f0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@maksymvavilov maksymvavilov moved this to Ready For Review in Kuadrant Jun 8, 2026
… docs

- Fix struct field alignment flagged by gofmt -s
- Handle base branch not having test-bench target yet by falling back
  to raw go test command
- Remove design doc .md files from PR

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Maskym Vavilov <mvavilov@redhat.com>
maksymvavilov and others added 3 commits June 9, 2026 12:28
Add 8 benchmarks from Mike Nairn's PR Kuadrant#2031 covering scaling dimensions
not in the original set: listener fanout, multi-gateway, RateLimitPolicy,
TokenRateLimitPolicy, GetKuadrantFromTopology lookup, topology build cost,
multi-reconciler cycle, and full reconciliation cycle.

Enhance topology builder with listenersPerGW, per-route policy attachment,
and TokenRateLimitPolicy support.

Co-Authored-By: Mike Nairn <mnairn@redhat.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Maskym Vavilov <mvavilov@redhat.com>
- Decouple benchmarks from unit tests with //go:build bench tag
- Remove redundant sub-benchmarks: TokenRateLimitPolicies (same code
  path as RateLimitPolicies), MultiReconcilerCycle (subset of
  FullReconciliationCycle), and oversized cases (1000-route, 64-listener)
- Bump -count from 6 to 10 for benchstat statistical significance
- Total suite runs in ~10.7 minutes with 40 sub-benchmarks, all with
  iters >= 2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Maskym Vavilov <mvavilov@redhat.com>
- Target only ./internal/controller/... instead of all UNIT_DIRS to
  avoid scanning unrelated packages
- Reuse make test-bench for base branch in CI workflow instead of
  duplicating the go test command

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Maskym Vavilov <mvavilov@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

1 participant