[ISSUE #10968] Copy transaction message properties directly instead of encode/decode roundtrip - #10970
Conversation
…tead of encode/decode roundtrip
There was a problem hiding this comment.
Pull request overview
This PR optimizes transaction end-message handling in the broker by replacing a properties encode/decode round-trip (used solely for deep-copying) with a direct map copy via MessageAccessor.deepCopyProperties(...), reducing unnecessary allocations during transaction commit/rollback.
Changes:
- Replace
MessageDecoder.messageProperties2String(...)+MessageDecoder.string2messageProperties(...)copy round-trip withMessageAccessor.deepCopyProperties(...)inEndTransactionProcessor#endMessageTransaction. - Preserve the existing final
propertiesStringencode afterclearProperty, keeping persisted wire-format behavior unchanged.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. Replacing the encode/decode roundtrip with MessageAccessor.deepCopyProperties(...) is a clean improvement. The method already exists and is used in TimerMessageStore and TimerMessageRocksDBStore, so this is consistent with established patterns. The behavior parity analysis in the PR description is thorough — the null/empty value path is indeed unreachable at this call site since msgExt properties come from the store decoder.
Automated review by github-manager-bot
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #10970 +/- ##
=============================================
- Coverage 48.56% 48.50% -0.07%
+ Complexity 13672 13652 -20
=============================================
Files 1381 1381
Lines 101475 101475
Branches 13190 13190
=============================================
- Hits 49286 49216 -70
- Misses 46185 46243 +58
- Partials 6004 6016 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes
Fixes #10968
Brief Description
EndTransactionProcessor#endMessageTransactiondeep-copied the prepare message's properties by encoding them to a String and immediately decoding that String back to a map:That is a full map traversal + StringBuilder + String, then a second traversal + per-entry substring allocations — on every transaction commit/rollback — just to copy a map. This PR replaces the round-trip with
MessageAccessor.deepCopyProperties(...). The real encode afterclearProperty(which produces the wire-formatpropertiesString) is untouched, so the stored message is byte-identical.Behavior parity note: the old round-trip silently dropped entries with null/empty values, but at this call site
msgExtis decoded from the store — the properties parser never yields null/empty values andputUserPropertyrejects blank values, so that path is unreachable here.How Did You Test This Change?
EndTransactionProcessorTestpasses (7/7).benchmark.TransactionProducer, 32 threads, 1 KiB body, all-commit; per arm clean store + broker restart + page cache drop; 25 s warmup + 60 s collect; 3 interleaved trials:Broker young GC per million messages: median 6.42 -> 6.14 (-4.4%), patch below base in all three trials; TPS flat; zero send failures.