Skip to content

[ISSUE #10197] Add traffic size distribution per requestCode in RemotingCodeDistributionHandler#10198

Open
RongtongJin wants to merge 3 commits intoapache:developfrom
RongtongJin:develop-0324
Open

[ISSUE #10197] Add traffic size distribution per requestCode in RemotingCodeDistributionHandler#10198
RongtongJin wants to merge 3 commits intoapache:developfrom
RongtongJin:develop-0324

Conversation

@RongtongJin
Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Brief Description

Add per-requestCode traffic size (bytes) distribution to RemotingCodeDistributionHandler, in addition to the existing request count distribution.

Key changes:

  • Replace 4 ConcurrentHashMaps with 2 using a composite TrafficStats class (LongAdder count + LongAdder trafficSize)
  • calcCommandSize() default path: fixed overhead (29 bytes) + body length — O(1), no iteration on hot path
  • enableDetailedTrafficSize in NettyServerConfig: when enabled, also counts remark + extFields byte lengths. Togglable at runtime via updateBrokerConfig
  • NettyRemotingServer.printRemotingCodeDistribution() now logs inbound/outbound traffic snapshots

How Did You Test This Change?

  • Added RemotingCodeDistributionHandlerTest with 10 unit test cases covering: count, traffic with/without body, detailed mode on/off, snapshot reset, multiple requestCodes, non-RemotingCommand passthrough, concurrent correctness, and runtime toggle
  • Added RemotingCodeDistributionBenchmark (JMH) comparing detail-off vs detail-on across 1/4/8 threads. recordInbound() is called directly (package-private) to isolate recording overhead from Netty pipeline cost

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 96.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.86%. Comparing base (e100743) to head (dd2bb4b).
⚠️ Report is 2 commits behind head on develop.

Files with missing lines Patch % Lines
...ing/protocol/remoting/RemotingProtocolHandler.java 0.00% 1 Missing ⚠️
...emoting/netty/RemotingCodeDistributionHandler.java 96.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10198      +/-   ##
=============================================
- Coverage      48.93%   48.86%   -0.08%     
+ Complexity     13384    13369      -15     
=============================================
  Files           1373     1373              
  Lines          99924    99940      +16     
  Branches       12908    12913       +5     
=============================================
- Hits           48898    48835      -63     
- Misses         45098    45161      +63     
- Partials        5928     5944      +16     

☔ 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.

Copy link
Copy Markdown
Contributor

@guyinyou guyinyou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Copy Markdown
Contributor

@fuyou001 fuyou001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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] Add traffic size distribution per requestCode in RemotingCodeDistributionHandler

5 participants