[ISSUE #10969] Hoist per-batch constant min/max offset strings out of message loop in PullAPIWrapper - #10971
Conversation
…out of message loop in PullAPIWrapper
There was a problem hiding this comment.
Pull request overview
This PR optimizes PullAPIWrapper#processPullResult by reducing per-message allocations when annotating pulled messages with batch-level min/max offsets, aligning with the hot-path allocation reduction described in Issue #10969.
Changes:
- Hoists
Long.toString(pullResult.getMinOffset()/getMaxOffset())out of the per-message loop. - Reuses the resulting
minOffset/maxOffsetstrings for all messages in the pull batch.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| String minOffset = Long.toString(pullResult.getMinOffset()); | ||
| String maxOffset = Long.toString(pullResult.getMaxOffset()); | ||
| for (MessageExt msg : msgListFilterAgain) { |
RockteMQ-AI
left a comment
There was a problem hiding this comment.
LGTM. Clean optimization — hoisting the two Long.toString() calls out of the per-message loop is correct since pullResult.getMinOffset() and pullResult.getMaxOffset() are constant within a single pull response. Reduces unnecessary short-lived string allocations on a hot path with zero behavior change.
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 #10971 +/- ##
=============================================
- Coverage 48.56% 48.50% -0.07%
+ Complexity 13672 13650 -22
=============================================
Files 1381 1381
Lines 101475 101475
Branches 13190 13190
=============================================
- Hits 49286 49216 -70
- Misses 46185 46245 +60
- Partials 6004 6014 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes
Fixes #10969
Brief Description
In
PullAPIWrapper#processPullResult, the per-message loop callsLong.toString(pullResult.getMinOffset())andLong.toString(pullResult.getMaxOffset())for every message, although both values are constant within one pull response. A 32-message batch allocates 64 identical short-lived strings where 2 suffice, on every pull response of every push/pull consumer.This PR hoists the two
Long.toStringcalls out of the loop and reuses the two strings for the whole batch. No behavior change: property values are identical andputPropertysemantics are untouched.How Did You Test This Change?
PullAPIWrapperTestpasses (11/11).