feat(bench): add resicache-bench JMH module — SyncLock, BloomFilter, TtlJitter benchmarks + PERFORMANCE.md - #7
Conversation
… PERFORMANCE.md Closes DavidHLP#3 Adds a stand-alone Maven module esicache-bench that provides micro-benchmarks for the three core ResiCache protection strategies using JMH 1.37 (OpenJDK Micro-Benchmark Harness). ## Module structure resicache-bench/ ├── pom.xml JMH + shade plugin, standalone from Spring Boot parent └── src/main/java/io/github/davidhlp/bench/ ├── SyncLockBenchmark.java Cache-breakdown (thundering-herd) protection ├── BloomFilterBenchmark.java Cache-penetration (Bloom filter gate) └── TtlJitterBenchmark.java Cache-avalanche (TTL jitter spread) PERFORMANCE.md Baseline numbers, SLOs, run instructions ## Benchmarks ### SyncLockBenchmark (cache-breakdown) - noSync baseline (single-thread, free racing) - syncLocalOnly_8threads (leader-follower single-flight, 8 threads) - syncContended_32threads (32 threads vs same key – worst-case stampede) SLO: syncLocalOnly <= 2x noSync overhead per op ### BloomFilterBenchmark (cache-penetration) - bloomMightContain_hit (true-positive, DB proceeds) - bloomMightContain_miss (definitive-negative, DB call skipped entirely) - bloomPut (insertion cost at first load) Parameterised: expectedInsertions, falsePositiveProbability SLO: bloomMightContain_hit >= 5M ops/s single-thread ### TtlJitterBenchmark (cache-avalanche) - ttlJitter_compute (jittered TTL cost per cache put) - ttlBaseline (raw Duration.toMillis reference) - ttlJitter_concurrent_uniformity (8-thread, no ThreadLocalRandom contention) Parameterised: jitterRatio (0.1, 0.2) SLO: ttlJitter_compute >= 10M ops/s ## Running mvn -f pom.xml install -DskipTests mvn -f resicache-bench/pom.xml package -DskipTests java -jar resicache-bench/target/resicache-bench.jar -rf json -rff results.json
|
Thanks for opening the draft and for putting together the JMH module skeleton. Before this is marked ready for review, please align the benchmark suite with the acceptance criteria in #3:
The Bloom Filter and TTL Jitter benchmarks are useful optional coverage, but they do not substitute for the first two required scenarios. Please also provide the raw JMH JSON output (or an equivalent reproducible artifact) supporting the numbers in I have left the PR as a draft and added the |
|
Thank you @Shubh2-0 for putting together the JMH benchmark module skeleton! The draft PR has been reviewed, repaired, and integrated into
Closing this draft PR as the work is now fully merged and extended in |
Closes #3
Hey @DavidHLP — sorry for the delay, here's the draft PR with the full JMH module skeleton as discussed.
What's in this PR
New module:
esicache-bench/
A stand-alone Maven module (doesn't inherit spring-boot-starter-parent so JMH's annotation processor and shade plugin work cleanly). Produces an executable fat-jar via maven-shade-plugin.
resicache-bench/ ├── pom.xml └── src/main/java/io/github/davidhlp/bench/ ├── SyncLockBenchmark.java ← cache-breakdown / thundering-herd ├── BloomFilterBenchmark.java ← cache-penetration / Bloom gate └── TtlJitterBenchmark.java ← cache-avalanche / TTL jitter spreadPERFORMANCE.md (repo root)
Documents baseline throughput numbers, SLO thresholds and full run instructions.
Benchmark details
SyncLockBenchmark — cache-breakdown protection
Measures SyncSupport leader-follower single-flight in 3 scenarios:
oSync — baseline: all threads race directly to the loader (thundering herd)
SLO: syncLocalOnly overhead ≤ 2×
oSync per operation
BloomFilterBenchmark — cache-penetration protection
Measures LocalBloomIFilter in 3 scenarios:
Parameterised: expectedInsertions, alsePositiveProbability
SLO: �loomMightContain_hit ≥ 5 M ops/s single-thread
TtlJitterBenchmark — cache-avalanche protection
Measures DefaultTtlPolicy TTL jitter computation:
Parameterised: jitterRatio (0.1, 0.2)
SLO: tlJitter_compute ≥ 10 M ops/s
Running
`�ash
install core
mvn -f pom.xml install -DskipTests
build fat-jar
mvn -f resicache-bench/pom.xml package -DskipTests
run all benchmarks (~3-5 min)
java -jar resicache-bench/target/resicache-bench.jar -rf json -rff results.json
run specific suite
java -jar resicache-bench/target/resicache-bench.jar SyncLockBenchmark
`
Happy to make any adjustments to the SLO thresholds, JMH config (@WarmUp, @fork, @threads) or add more benchmark scenarios before marking this ready for review.