You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "wang-jiahua (via GitHub)" <gi...@apache.org> on 2026/08/27 06:31:39 UTC

[I] [Enhancement] Hoist per-batch constant MIN_OFFSET/MAX_OFFSET strings out of the per-message loop in PullAPIWrapper [rocketmq]

wang-jiahua opened a new issue, #10969:
URL: https://github.com/apache/rocketmq/issues/10969

   ### Before Creating the Enhancement Request
   
   - [x] I have confirmed that this should be classified as an enhancement rather than a bug/feature.
   
   ### Summary
   
   `PullAPIWrapper#processPullResult` re-stringifies `pullResult.getMinOffset()` / `getMaxOffset()` for every message in the batch, although both values are constant within one pull response.
   
   ### Motivation
   
   In the per-message loop, `MessageAccessor.putProperty(msg, PROPERTY_MIN_OFFSET, Long.toString(pullResult.getMinOffset()))` (and the MAX_OFFSET counterpart) allocates two new strings per message with identical content. A 32-message batch allocates 64 strings where 2 suffice; this runs on every pull response of every push/pull consumer.
   
   ### Solution
   
   Hoist the two `Long.toString` calls out of the loop and reuse the two strings for the whole batch. No behavior change: the property values are identical, `putProperty` semantics untouched.
   
   ### Verification
   
   - `PullAPIWrapperTest` 11/11 passed.
   - Joint benchmark on a 4-node cluster (producer 64 threads + consumer 20 threads, 1 KiB, consumer-side client jar swapped per arm, 3 interleaved 60 s trials): consumer young GC per million consumed messages 1.10/1.06/1.17 (base) vs 1.08/1.06/1.07 (patch), consume TPS flat — no regression. The allocation saving itself is small (tens of short-lived strings per batch) and below GC-count resolution; this is a trivial cleanup-level optimization on a hot path.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Enhancement] Hoist per-batch constant MIN_OFFSET/MAX_OFFSET strings out of the per-message loop in PullAPIWrapper [rocketmq]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #10969:
URL: https://github.com/apache/rocketmq/issues/10969#issuecomment-5440343770

   **Issue Evaluation**
   
   Category: enhancement | Status: **Evaluated**
   
   **Feasibility:** Feasible
   **Scope:** Performance optimization — no API/protocol changes
   **Compatibility:** Backward compatible
   
   This is a well-scoped performance improvement targeting Hoist per-batch constant MIN_OFFSET/MAX_OFFSET strings. The analysis is specific and the proposed change reduces unnecessary allocation/encoding overhead.
   
   This type of incremental optimization is valuable for high-throughput scenarios.
   
   ---
   *Automated evaluation by github-manager*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Enhancement] Hoist per-batch constant MIN_OFFSET/MAX_OFFSET strings out of the per-message loop in PullAPIWrapper [rocketmq]

Posted by "RockteMQ-AI (via GitHub)" <gi...@apache.org>.
RockteMQ-AI commented on issue #10969:
URL: https://github.com/apache/rocketmq/issues/10969#issuecomment-5435606341

   **Issue Evaluation**
   
   Category: `type/enhancement` | Status: **Evaluated**
   
   **Feasibility:** feasible
   **Scope:** `PullAPIWrapper#processPullResult` (client module)
   **Compatibility:** no behavior change — property values are identical, `putProperty` semantics untouched
   
   This is a valid micro-optimization. Hoisting the two `Long.toString()` calls out of the per-message loop eliminates redundant string allocations on every pull response. The analysis is correct: `minOffset` and `maxOffset` are constant within a single pull result, so computing them once per batch is sufficient.
   
   The benchmark data shows no regression and a slight improvement in young GC pressure, which is consistent with the reduced allocation rate.
   
   **Recommendation:** proceed — this is a clean, low-risk cleanup on a hot path.
   
   ---
   *Automated evaluation by github-manager-bot*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Enhancement] Hoist per-batch constant MIN_OFFSET/MAX_OFFSET strings out of the per-message loop in PullAPIWrapper [rocketmq]

Posted by "RongtongJin (via GitHub)" <gi...@apache.org>.
RongtongJin closed issue #10969: [Enhancement] Hoist per-batch constant MIN_OFFSET/MAX_OFFSET strings out of the per-message loop in PullAPIWrapper
URL: https://github.com/apache/rocketmq/issues/10969


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org