Avoid serializing inline Azure Storage queue messages twice - #1380
Open
berndverst wants to merge 2 commits into
Open
Avoid serializing inline Azure Storage queue messages twice#1380berndverst wants to merge 2 commits into
berndverst wants to merge 2 commits into
Conversation
added 2 commits
July 27, 2026 13:38
Reuse the MessageData JSON already produced for size selection when the payload remains inline. Add exact wire-equivalence and threshold-path regression coverage for both serialization modes and a custom binder. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9509e194-db0b-4024-b7b0-26481278e0db
Verify exact inline payload equivalence, single-pass custom binder behavior, and the inline/blob boundary for both data-contract serialization modes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 9509e194-db0b-4024-b7b0-26481278e0db
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes a redundant JSON serialization on the common inline-queue-message path in MessageManager.SerializeMessageDataAsync, reusing the already-produced JSON payload that was generated for the UTF-8 size check. It adds regression tests to assert byte-for-byte equivalence with the prior “serialize twice” behavior (including custom type binder behavior and both UseDataContractSerialization modes), and to validate behavior at the exact 45 KiB inline threshold and just above it (blob offload + wrapper).
Changes:
- Reuse the initial
rawContentJSON string for inline queue payloads instead of serializingMessageDataa second time. - Add tests validating inline payload equivalence (including custom binder behavior) in both
UseDataContractSerializationmodes. - Add boundary tests covering the exact 45 KiB inline cutoff and the above-threshold blob-wrapper path (including verifying stored blob content).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/DurableTask.AzureStorage/MessageManager.cs | Avoids duplicate serialization by returning the already-generated rawContent for inline messages. |
| test/DurableTask.AzureStorage.Tests/MessageManagerTests.cs | Adds regression coverage for inline payload equivalence and for inline/blob behavior at and above the 45 KiB threshold. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
MessageDataJSON already produced for the UTF-8 size check when a queue message stays inlineUseDataContractSerializationmodesBackward compatibility
The initial serialization already determines both the queue payload size and the inline/blob decision.
TotalMessageSizeBytesis internal and is not a data member, so returning that existing JSON on the inline path is byte-for-byte equivalent to the previous second serialization. The size threshold, serializer configuration, public APIs, blob upload content, and blob-reference wrapper serialization are unchanged.Testing
dotnet test Test\DurableTask.AzureStorage.Tests\DurableTask.AzureStorage.Tests.csproj --framework net8.0 --filter "FullyQualifiedName~DurableTask.AzureStorage.Tests.MessageManagerTests"dotnet test Test\DurableTask.AzureStorage.Tests\DurableTask.AzureStorage.Tests.csproj --framework net48 --filter "FullyQualifiedName~DurableTask.AzureStorage.Tests.MessageManagerTests"Fixes #1378