test: Add JMH benchmark suite for PubSub implementations#390
Open
iamabhilaksh wants to merge 4 commits intosalesforce:mainfrom
Open
test: Add JMH benchmark suite for PubSub implementations#390iamabhilaksh wants to merge 4 commits intosalesforce:mainfrom
iamabhilaksh wants to merge 4 commits intosalesforce:mainfrom
Conversation
Implement comprehensive performance benchmarks for AWS SNS and GCP Pub/Sub: - 13 benchmarks for AWS (publishing, consuming, end-to-end, edge cases) - 14 benchmarks for GCP (includes additional NACK/redelivery test) - Both Throughput and SampleTime modes for latency percentiles - Concurrent execution with @threads annotation Key changes: - Add AbstractPubsubBenchmarkTest.java with 14 benchmark scenarios - Add AwsSnsPubsubBenchmarkTest.java and GcpPubsubBenchmarkTest.java - Add JMH dependencies to pubsub-client, pubsub-aws, pubsub-gcp - Implement ensurePrePopulated() helper to eliminate code duplication - Extract magic numbers to named constants for maintainability - Fix benchmarkMaxSizeMessages to use 100KB (was 256KB) to stay within AWS SNS 256KB batch limit Benchmarks cover: - Publishing: single, sequential, tiny/medium/large messages, attributes, max size - Consuming: single message, batch ack, large batch ack - End-to-end: publish-consume-ack pipeline, high throughput pipeline, message backlog - Edge cases: max size messages - Provider-specific: NACK and redelivery (GCP only) Code quality improvements: - Refactored GCP NACK benchmark to use parent helper method (consistency) - Removed unused MAX_MESSAGE constant - All magic numbers extracted to named constants with clear purpose - Thread-safe pre-population with double-checked locking pattern Establishes performance baselines for both AWS and GCP implementations.
- Line 60: Shortened NACK comment from 105 to 99 chars - Line 66: Shortened availability comment from 108 to 99 chars
- Fix line 60 checkstyle: shorten comment from 101 to 88 chars - Change ensurePrePopulated() from private to protected (needed by GCP subclass) - Add @disabled to AwsSnsPubsubBenchmarkTest (follows blobstore pattern) - Add @disabled to GcpPubsubBenchmarkTest (follows blobstore pattern) This prevents benchmarks from running in CI while keeping them compilable and easily enableable for manual execution.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #390 +/- ##
=========================================
Coverage 82.10% 82.11%
Complexity 641 641
=========================================
Files 194 194
Lines 11798 11798
Branches 1572 1572
=========================================
+ Hits 9687 9688 +1
+ Misses 1434 1433 -1
Partials 677 677
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📊 Overview
This PR introduces a comprehensive JMH (Java Microbenchmark Harness) benchmark suite for PubSub implementations across AWS SNS/SQS and GCP Pub/Sub. The benchmarks establish performance baselines and enable continuous performance monitoring.
✨ Features
Benchmark Coverage
Throughput- Operations per microsecondSampleTime- Latency distribution with percentiles (p50, p90, p99, p99.9)Benchmark Categories
Publishing (7 benchmarks)
benchmarkSingleMessagePublish- Concurrent publishing (4 threads)benchmarkSequentialPublish- Single-threaded baselinebenchmarkPublishTinyMessages- 256 bytes payloadbenchmarkPublishMediumMessages- 10KB payloadbenchmarkPublishLargeMessages- 100KB payloadbenchmarkPublishWithAttributes- Metadata overhead measurementbenchmarkMaxSizeMessages- Max size (100KB) stress testConsuming (3 benchmarks)
benchmarkSingleMessageReceive- Receive + ack latencybenchmarkBatchAck- Batch acknowledgment efficiency (10 messages)benchmarkLargeBatchAck- Large batch scaling (AWS: 10, GCP: 100)End-to-End (3 benchmarks)
benchmarkPublishConsumeAck- Full pipeline latencybenchmarkHighThroughputPipeline- Max sustainable throughput (8 threads)benchmarkMessageBacklog- Backlog recovery performance (5000 messages)Provider-Specific (1 benchmark)
benchmarkNackAndRedelivery- GCP NACK/redelivery latency (GCP only)📈 Benchmark Results
AWS SNS/SQS Performance
Duration: 56 minutes | Status: ✅ Complete (26/26 results)
GCP Pub/Sub Performance
Duration: 117 minutes | Status: ✅ Excellent (27/28 results)
Note: benchmarkMessageBacklog SampleTime mode data missing due to timeout
Key Insights
🏗️ Implementation Details
Code Structure
pubsub/
├── pubsub-client/
│ ├── pom.xml # Added JMH dependencies
│ └── src/test/java/.../client/
│ └── AbstractPubsubBenchmarkTest.java # Base benchmark class (670 lines)
├── pubsub-aws/
│ ├── pom.xml # Added JMH dependencies
│ └── src/test/java/.../aws/
│ └── AwsSnsPubsubBenchmarkTest.java # AWS implementation (96 lines)
└── pubsub-gcp/
├── pom.xml # Added JMH dependencies
└── src/test/java/.../gcp/
└── GcpPubsubBenchmarkTest.java # GCP implementation (136 lines)
Code Quality Improvements
✅ Eliminated Code Duplication
ensurePrePopulated()helper method✅ Extracted Magic Numbers to Constants
✅ Fixed AWS SNS Batch Limit Issue
✅ Consistent Pre-Population Pattern
🧪 Running Benchmarks
Run Full AWS Benchmark Suite
Run Full GCP Benchmark Suite
Results Location
AWS Results
GCP Results
📦 Full Benchmark Results
Due to size limitations (AWS: 221KB, GCP: 197KB), full JMH JSON results are available:
AWS SNS/SQS Results (221KB, 26 results)
GCP Pub/Sub Results (197KB, 27 results)
Contact maintainer for full JSON files or generate them by running the benchmarks.
GCP Timeouts (Minor, Non-Blocking)
- Throughput mode data complete
- Root cause: Consumer timeout in long-running backlog test
Disabled Benchmarks (Future Work)
Saved in backup for future implementation:
🔍 Testing Checklist
🎯 Next Steps
📚 Related Documentation
Performance baselines established! 🚀 Ready for continuous monitoring and optimization.