Skip to content

[ISSUE #10486] Add getMessageType(Map) overload to eliminate redundant properties decode#10487

Open
wang-jiahua wants to merge 1 commit into
apache:developfrom
wang-jiahua:perf/metrics-getmessagetype-map-overload
Open

[ISSUE #10486] Add getMessageType(Map) overload to eliminate redundant properties decode#10487
wang-jiahua wants to merge 1 commit into
apache:developfrom
wang-jiahua:perf/metrics-getmessagetype-map-overload

Conversation

@wang-jiahua

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #10486

Brief Description

BrokerMetricsManager.getMessageType(SendMessageRequestHeader) is called once per send to classify the message (NORMAL/TRANSACTION/DELAY/FIFO). It internally decodes the properties String into a HashMap, but the typical caller (SendMessageProcessor) has already decoded the same String moments before. The result is a redundant decode allocation per send (one HashMap + ~14 String substrings + one Node[]).

This PR adds a public overload getMessageType(Map<String, String>) that lets callers pass an already-decoded Map and reuse it. The existing SendMessageRequestHeader overload now delegates to the new overload; behavior is unchanged for callers that don't have a decoded Map.

// new public overload
public static TopicMessageType getMessageType(Map<String, String> properties) { ... }

// existing overload now delegates
public static TopicMessageType getMessageType(SendMessageRequestHeader requestHeader) {
    return getMessageType(MessageDecoder.string2messageProperties(requestHeader.getProperties()));
}

Downstream callers (e.g. SendMessageProcessor) can switch to the new overload in a separate broker-layer commit.

How Did You Test This Change?

  • Existing BrokerMetricsManagerTest (27 tests) passes. The behavior of the original overload is preserved by delegation.
  • The new overload uses the exact same key-lookup logic as before, only sourced from a passed-in Map instead of a freshly decoded one.

Independence

This PR is independent of #10443 and #10481 — it doesn't reference any new constants and only restructures BrokerMetricsManager.getMessageType(...) (1 file, +4/-1).

…dundant properties decode

BrokerMetricsManager.getMessageType(SendMessageRequestHeader) is called
once per send to classify the message. It internally decodes the
properties String into a HashMap, but the typical caller
(SendMessageProcessor) has already decoded the same String moments
before. The result is a redundant decode allocation per send (one
HashMap + ~14 String substrings + one Node[]).

This commit adds a public overload getMessageType(Map<String, String>)
that lets callers pass an already-decoded Map and reuse it. The
existing SendMessageRequestHeader overload now delegates to the new
overload; behavior is unchanged for callers that don't have a decoded
Map. Downstream callers (e.g. SendMessageProcessor) can switch to the
new overload in a separate broker-layer commit.
Copilot AI review requested due to automatic review settings June 11, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors message-type detection to centralize logic based on parsed message properties, improving reuse and reducing duplication.

Changes:

  • Changes getMessageType(SendMessageRequestHeader) to delegate after parsing properties.
  • Introduces an overload getMessageType(Map<String, String>) containing the core logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.02%. Comparing base (82a6a78) to head (cb4ff2e).
⚠️ Report is 15 commits behind head on develop.

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10487      +/-   ##
=============================================
- Coverage      48.06%   48.02%   -0.05%     
+ Complexity     13313    13300      -13     
=============================================
  Files           1377     1377              
  Lines         100632   100656      +24     
  Branches       12995    12996       +1     
=============================================
- Hits           48369    48340      -29     
- Misses         46344    46369      +25     
- Partials        5919     5947      +28     

☔ View full report in Codecov by Harness.
📢 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.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review: Approved ✅

PR: #10487 — Add getMessageType(Map) overload to eliminate redundant properties decode
Type: Performance (1 file, +4/-1)

Assessment

Eliminates redundant MessageDecoder.string2messageProperties() call in the send hot path. Adds a getMessageType(Map) overload so callers can pass the already-decoded properties map.

Verdict

✅ Clean, minimal change. Fixes #10486.


🤖 Automated review by oss-sentinel-ai

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 getMessageType(Map) overload to eliminate redundant properties decode in send path

5 participants