[performance] Reduce Java Event Hubs hot-path overhead and scheduler churn#48617
Open
videlalvaro wants to merge 7 commits intoAzure:mainfrom
Open
[performance] Reduce Java Event Hubs hot-path overhead and scheduler churn#48617videlalvaro wants to merge 7 commits intoAzure:mainfrom
videlalvaro wants to merge 7 commits intoAzure:mainfrom
Conversation
Contributor
|
Thank you for your contribution @videlalvaro! We will review the pull request and get back to you soon. |
68f5fed to
d9bfdd9
Compare
d9bfdd9 to
7f4ecaf
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes several internal hot paths in the Java Event Hubs client (batch send, message conversion, buffered producer scheduling, and timeout scheduling) and adds targeted regression coverage plus audit/benchmark artifacts.
Changes:
- Cache and reuse Proton
Messageinstances created duringEventDataBatch.tryAdd()when sending a batch. - Reduce transient allocation churn in
MessageUtils(map conversion + ProtonPropertiescreation). - Align internal scheduling behavior (buffered producer uses client scheduler; sync receive timeouts use a shared scheduler; batch timeout reset uses a single delayed stream) and add tests/audit artifacts.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventDataBatch.java | Cache AMQP Message objects per batch and reuse for sizing/send. |
| sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClient.java | Send path reuses cached batch messages; exposes scheduler accessor for internal reuse. |
| sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/implementation/MessageUtils.java | Reduce allocation churn in map conversion and property creation. |
| sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubBufferedPartitionProducer.java | Buffered publishing uses producer client scheduler rather than global boundedElastic. |
| sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventDataAggregator.java | Replace interval-based timeout reset with sink-driven switchMap(Mono.delay(...)). |
| sdk/eventhubs/azure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/implementation/SynchronousEventSubscriber.java | Replace per-subscriber Timer with a shared scheduled executor and cancelable tasks. |
| sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventDataBatchTest.java | Adds coverage for cached serialized message creation and partition-key annotations. |
| sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubProducerAsyncClientTest.java | Adds coverage that send(batch) reuses cached messages and doesn’t re-serialize. |
| sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/MessageUtilsTest.java | Adds tests for empty-map conversion and Instant→Date conversion. |
| sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/implementation/AmqpReceiveLinkProcessorTest.java | Adds regression checks for bounded buffering and credit calculation (via reflection). |
| sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/EventHubBufferedPartitionProducerTest.java | Adds test that buffered callbacks run on the client’s configured scheduler. |
| sdk/eventhubs/azure-messaging-eventhubs/src/test/java/com/azure/messaging/eventhubs/implementation/SynchronousEventSubscriberTest.java | Adds regression test for shared sync timeout scheduling behavior. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/SUMMARY.md | Adds audit summary document for the investigated perf/security findings. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/pom.xml | Adds a standalone benchmark module POM for performance checks. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/Benchmark.java | Adds an emulator-oriented benchmark runner. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/001-repeated-message-encoding/REPORT.md | Documents PERF-001 rationale and validation. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/001-repeated-message-encoding/PR_DRAFT.md | PR draft notes for PERF-001. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/001-repeated-message-encoding/benchmark.java | Adds benchmark script artifact for PERF-001. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/001-repeated-message-encoding/fix.patch | Adds patch artifact showing a candidate fix for PERF-001. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/002-unbounded-message-queue/REPORT.md | Documents that buffering is already bounded and adds test-only follow-up. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/002-unbounded-message-queue/PR_DRAFT.md | PR draft notes for PERF-002 regression coverage. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/002-unbounded-message-queue/fix.patch | Adds patch artifact for PERF-002 (not applied to product code). |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/003-message-object-allocation/REPORT.md | Documents allocation-churn findings and the implemented mitigation. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/003-message-object-allocation/PR_DRAFT.md | PR draft notes for PERF-003. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/004-scheduler-pool-exhaustion/REPORT.md | Documents buffered producer scheduler fix scope and validation. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/004-scheduler-pool-exhaustion/PR_DRAFT.md | PR draft notes for PERF-004. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/005-timer-per-subscriber/REPORT.md | Documents sync timeout scheduler refactor and validation. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/005-timer-per-subscriber/PR_DRAFT.md | PR draft notes for PERF-005. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/006-flux-interval-overhead/REPORT.md | Documents interval-churn findings and switchMap delay approach. |
| sdk/eventhubs/azure-messaging-eventhubs/audit-reports/performance/006-flux-interval-overhead/PR_DRAFT.md | PR draft notes for PERF-006. |
...ure-messaging-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventDataAggregator.java
Show resolved
Hide resolved
...s/src/main/java/com/azure/messaging/eventhubs/implementation/SynchronousEventSubscriber.java
Outdated
Show resolved
Hide resolved
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.
Summary
This PR improves several internal Java Event Hubs hot paths.
Included changes:
Two related areas did not require new product changes:
What Changed
EventDataBatchinstead of serializing the same events twice.MessageUtilswith simpler pre-sized conversion logic.EventDataAggregator.Validation
Focused unit validation:
EventDataBatchTestandEventHubProducerAsyncClientTestpassed for the batch-send reuse path.AmqpReceiveLinkProcessorTestpassed for bounded receive buffering coverage.MessageUtilsTestandEventHubMessageSerializerTestpassed for message-conversion changes.EventHubBufferedPartitionProducerTestpassed for buffered producer scheduler behavior.Emulator-backed benchmark checks were run with the local benchmark harness.
Combined branch results versus clean baseline:
Repeated measurements for the main change areas, 5 samples each:
71758 msgs/sec; median send times10 ms,9 ms,5 msfor 100 / 500 / 1000 events.0.97 ms; median rich-message add14.33 us.5367 msgs/sec,0failed batches.5759 msgs/sec,0failed batches.Notes:
Risk
Risk is low to moderate and localized to internal hot paths.
Reviewer Notes