Avoid serializing inline Azure Storage queue messages twice
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- azure, csharp
- Domain
- backend, cloud, performance
Research direction
Start in src/DurableTask.AzureStorage/MessageManager.cs at SerializeMessageDataAsync, then inspect MessageData.cs, Utils.cs, and Messaging/TaskHubQueue.cs to understand the inline and blob paths. Add regression coverage for both serialization modes, binder settings, and threshold boundaries, then compare the inline output and run allocation benchmarks. Done means inline messages serialize once while blob behavior and wire output remain unchanged.
Written by the indexing model from the issue text.
Description
What is the issue
MessageManager.SerializeMessageDataAsync serializes every MessageData instance into rawContent, uses that string to calculate its UTF-8 size and select inline versus blob storage, and then serializes the same object a second time in the common InlineJson branch:
The only mutation between those two serializations is TotalMessageSizeBytes. That property is internal and is not a [DataMember], while MessageData is a [DataContract] whose wire properties are explicitly marked:
Each serialization also creates a fresh StringBuilder, StringWriter, and result string:
This method is called for every outbound Azure Storage task-hub queue message:
The blob-offload branch legitimately serializes a small wrapper after uploading rawContent; only the inline branch repeats the original serialization.
Performance impact
Inline messages are the normal path for payloads below the 45 KiB threshold. Every such orchestration, activity, timer, sub-orchestration, and external-event message currently incurs two complete Newtonsoft JSON traversals and two sets of temporary buffers/strings instead of one.
The duplicate CPU and allocation cost scales linearly with message throughput and payload size. At high task-hub throughput this increases serialization CPU, memory bandwidth, Gen-0 pressure, and queue-send latency without changing the resulting wire payload.
Proposed backward-compatible solution
Return the already-produced rawContent in the InlineJson branch:
if (messageFormat != MessageFormatFlags.InlineJson)
{
// Existing blob upload and wrapper serialization remain unchanged.
}
return rawContent;
This preserves the exact JSON that was already used for the byte-count/format decision. It changes no public API, queue schema, serializer settings, or blob behavior.
Validation
- Add regression coverage for both
UseDataContractSerializationmodes and representative custom type-binder settings, asserting that the optimized inline result exactly matches the current second serialization. - Cover payloads immediately below and above the inline threshold to ensure the blob-wrapper path is unchanged.
- Benchmark representative small, medium, and near-threshold messages with allocation diagnostics; the inline path should perform one
MessageDataserialization instead of two.
- Dominant language
- C#
- Stars
- 1.7k
- Forks
- 335
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 6
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/durabletask
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Azure/durabletask#1398 · 2 comments ·
-
Azure/durabletask#1389 · 1 comment · 1 assignee ·
-
Difficulty 3/5 1-2 days Newbie friendliness 74/100
Azure/durabletask#1376 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Azure/durabletask#1332 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Azure/durabletask#1318 · 1 comment ·
All issues in Azure/durabletask
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·