Skip to content

bench(storage,cache,pubsub): add hot-path benchmarks#503

Merged
zeevdr merged 1 commit into
mainfrom
bench/hot-paths
May 19, 2026
Merged

bench(storage,cache,pubsub): add hot-path benchmarks#503
zeevdr merged 1 commit into
mainfrom
bench/hot-paths

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 19, 2026

Summary

  • Hot paths (cache, pubsub, storage queries) had no benchmarks, making it impossible to detect regressions or measure optimization impact.
  • Adds BenchmarkMemoryCache_Hit/Miss/SetEvictsOldest and BenchmarkRedisCache_Get/Set/Invalidate (Redis skipped when REDIS_URL unset).
  • Adds BenchmarkMemoryPubSub_Publish/FanOut (0–50 subscribers) and BenchmarkRedisPubSub_Publish/FanOut (Redis skipped when REDIS_URL unset).
  • Adds BenchmarkSetConfigValue, BenchmarkGetFullConfigAtVersion, and BenchmarkListTenants against a real Postgres pool, with full schema→tenant→config_version fixture setup and cleanup (skipped when DB_WRITE_URL unset).
  • CI bench job extended: adds new packages, runs -count=5 for benchstat, and uploads both raw results and percentile summary as artifacts.

Test plan

  • go test -bench=^BenchmarkMemoryCache -benchmem -benchtime=500ms ./internal/cache/ — three benchmarks run and complete cleanly.
  • go test -bench=^BenchmarkMemoryPubSub -benchmem -benchtime=500ms ./internal/pubsub/ — publish and fan-out (1/10/50 subs) benchmarks run cleanly.
  • go test -bench=. -benchmem -run='^$' -benchtime=500ms ./internal/storage/dbstore/ — skips cleanly when DB_WRITE_URL is unset.
  • Redis benchmarks skip (not fail) when REDIS_URL is unset.
  • CI bench job produces bench.txt and bench-stats.txt artifacts.

Closes #473

🤖 Generated with Claude Code

Add benchmark suites for the three hot paths identified in #473:

- internal/cache: MemoryCache hit/miss/eviction; RedisCache
  get/set/invalidate (skipped when REDIS_URL is unset)
- internal/pubsub: MemoryPubSub publish with 0/1/10/50 subscribers;
  RedisPubSub publish and fan-out (skipped when REDIS_URL is unset)
- internal/storage/dbstore: SetConfigValue, GetFullConfigAtVersion,
  ListTenants against a real Postgres pool (skipped when DB_WRITE_URL
  is unset); fixture sets up schema→version→tenant→config_version and
  cleans up on b.Cleanup

CI bench job extended to include the new packages, run with -count=5
for benchstat percentile output, and pipe results through benchstat to
surface p50/p95 in the uploaded artifact.

Closes #473

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 19, 2026
@zeevdr zeevdr added enhancement New feature or request server Server changes size: M Moderate — a day or two, clear scope priority: P0 Blocks alpha or release labels May 19, 2026
@zeevdr zeevdr enabled auto-merge (squash) May 19, 2026 18:20
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zeevdr zeevdr merged commit 0483914 into main May 19, 2026
23 checks passed
@zeevdr zeevdr deleted the bench/hot-paths branch May 19, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: P0 Blocks alpha or release server Server changes size: M Moderate — a day or two, clear scope

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bench: storage queries (sqlc-generated), cache hit/miss, pubsub fanout

1 participant