Remove per-message Task.Run from Service Bus deserialization - #1379
Open
berndverst wants to merge 1 commit into
Open
Remove per-message Task.Run from Service Bus deserialization#1379berndverst wants to merge 1 commit into
berndverst wants to merge 1 commit into
Conversation
Return completed stream tasks for inline message bodies while retaining asynchronous blob-store loading. Add cross-target coverage for round trips, synchronous completion, and stream ownership. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1347830a-17c5-4248-8e41-fee30d3066b4
| message.UserProperties[FrameworkConstants.CompressionTypePropertyName] = | ||
| FrameworkConstants.CompressionTypeNonePropertyValue; | ||
|
|
||
| var stream = new MemoryStream(); |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes per-message Task.Run scheduling from inline Service Bus message stream loading by returning already-completed Task<Stream> instances, reducing thread-pool work-item bursts during batch deserialization.
Changes:
- Replace
Task.Run(...)withTask.FromResult(...)for inline message bodies inServiceBusUtils.LoadMessageStreamAsync(bothNETSTANDARD2_0andnet48branches). - Add new unit tests intended to validate inline (compressed/uncompressed) round trips, synchronous completion for uncompressed inline messages, and async blob-store behavior/stream ownership for external messages.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/DurableTask.ServiceBus/Common/ServiceBusUtils.cs |
Removes thread-pool hop for inline message-body stream creation by returning completed tasks. |
Test/DurableTask.ServiceBus.Tests/ServiceBusUtilsTests.cs |
Adds tests for inline/external deserialization behaviors, but currently placed in a directory not used by the active test project. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+18
| namespace DurableTask.ServiceBus.Tests | ||
| { | ||
| using System; | ||
| using System.IO; | ||
| using System.Threading.Tasks; |
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
Task<Stream>for inline Service Bus message bodies on bothnetstandard2.0andnet48MemoryStream/GetBody<Stream>()behavior and leave external blob-store loading asynchronousCompatibility and performance
The private
Task<Stream>contract is unchanged, as are the inline stream contents, initial position, and disposal lifetime. The blob-backed branch still returnsLoadStreamAsyncdirectly. Inline messages no longer allocate and queue aTask.Runwork item, avoiding per-message thread-pool scheduling and batch bursts at the default prefetch size.Tests
dotnet test Test\DurableTask.ServiceBus.Tests\DurableTask.ServiceBus.Tests.csproj -f net8.0 --filter "FullyQualifiedName~ServiceBusUtilsTests"dotnet test Test\DurableTask.ServiceBus.Tests\DurableTask.ServiceBus.Tests.csproj -f net48 --filter "FullyQualifiedName~ServiceBusUtilsTests"Fixes #1376