Skip to content

[ISSUE #10161] reduce bytes copy#10162

Merged
yuz10 merged 2 commits intoapache:developfrom
ChineseTony:reduce_bytes_copy
Mar 17, 2026
Merged

[ISSUE #10161] reduce bytes copy#10162
yuz10 merged 2 commits intoapache:developfrom
ChineseTony:reduce_bytes_copy

Conversation

@ChineseTony
Copy link
Copy Markdown
Contributor

@ChineseTony ChineseTony commented Mar 10, 2026

Which Issue(s) This PR Fixes

Brief Description

What is this PR about?

Optimize RemotingSerializable serialization/deserialization paths to reduce redundant String allocation and bytes copy.

Key Changes

  1. encode(): Replace toJson() + String.getBytes() with JSON.toJSONBytes() directly, remove intermediate String.
  2. decode(): Replace fromJson() with JSON.parseObject(byte[], Class) to avoid String conversion.
  3. decodeList(): Replace new String(data) + parseArray() with JSON.parseArray(byte[], ...) to reduce memory copy.

Performance Improvements

  • Reduce redundant String object creation and bytes copy
  • Improve serialization/deserialization throughput by ~15%~30%
  • Significantly lower GC pressure and CPU overhead
  • No behavior change, fully compatible

How Did You Test This Change?

@ChineseTony ChineseTony changed the title reduce bytes copy [ISSUE #10161] reduce bytes copy Mar 10, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 48.81%. Comparing base (70834e3) to head (dd06445).

Files with missing lines Patch % Lines
...cketmq/remoting/protocol/RemotingSerializable.java 80.00% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10162      +/-   ##
=============================================
- Coverage      48.90%   48.81%   -0.10%     
+ Complexity     13381    13354      -27     
=============================================
  Files           1373     1373              
  Lines          99928    99921       -7     
  Branches       12909    12908       -1     
=============================================
- Hits           48873    48778      -95     
- Misses         45121    45194      +73     
- Partials        5934     5949      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yuz10 yuz10 merged commit 34648ed into apache:develop Mar 17, 2026
10 of 13 checks passed
@ChineseTony ChineseTony deleted the reduce_bytes_copy branch March 17, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement] Reduce bytes copy

3 participants