wang-jiahua opened a new pull request, #10526: URL: https://github.com/apache/rocketmq/pull/10526
<!-- Please make sure the target branch is right. In most case, the target branch should be `develop`. --> ### Which Issue(s) This PR Fixes <!-- Please ensure that the related issue has already been created, and [link this pull request to that issue using keywords](<https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword>) to ensure automatic closure. --> Fixes #10525 ### Brief Description Reduce allocation in the pull/dispatch path through five independent optimizations: 1. **`GetMessageResult`** — Replace `List<Long>` with `long[]` + `addQueueOffset(long)` method. Eliminates `Long` boxing and `ArrayList` resize overhead. Right-sized initial capacity via constructor parameter. 2. **`DispatchRequest`** — Change `final` fields to mutable + add `reset()` method for ThreadLocal reuse. Eliminates per-message `DispatchRequest` allocation in the dispatch hot path. 3. **`DefaultMappedFile`** — Cache append slice and merge dual-slice operation in `selectMappedBuffer`. Eliminates redundant `ByteBuffer.slice()` allocation. 4. **`DefaultMessageStore`** — Remove `thenAccept` callback lambda in `putMessage`/`putMessages`. Eliminates per-message closure allocation (captures `this` + `beginTime`). 5. **`ConsumeQueue`** — Make `topicQueueKey` a `final` field to avoid per-call string computation. ### How Did You Test This Change? 1. **Unit tests**: All 62 tests pass (`EscapeBridgeTest`, `PopConsumerServiceTest`, `PopLiteMessageProcessorTest`). 2. **Compilation**: `store` + `broker` modules compile cleanly on JDK 21. 3. **Commercial compatibility**: No commercial classes extend `GetMessageResult`, `DefaultMappedFile`, `DispatchRequest`, `ConsumeQueue`, or `DefaultMessageStore`. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
