You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by GitBox <gi...@apache.org> on 2023/01/11 15:07:36 UTC

[GitHub] [rocketmq] mxsm opened a new pull request, #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

mxsm opened a new pull request, #5870:
URL: https://github.com/apache/rocketmq/pull/5870

   **Make sure set the target branch to `develop`**
   
   ## What is the purpose of the change
   
   close #5859 
   
   ## Brief changelog
   
   - Optimize String#format in DefaultMQProducerImpl
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


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


[GitHub] [rocketmq] mxsm commented on a diff in pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
mxsm commented on code in PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870#discussion_r1067672501


##########
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java:
##########
@@ -695,16 +695,13 @@ private SendResult sendDefaultImpl(
             if (sendResult != null) {
                 return sendResult;
             }
+            StringBuilder info = new StringBuilder(300);
+            info.append("Send [").append(times).append("] times, still failed, cost [")
+                .append(System.currentTimeMillis() - beginTimestampFirst).append("]ms, Topic: ").append(msg.getTopic())
+                .append(", BrokersSent: ").append(Arrays.toString(brokersSent))
+                .append(FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED));

Review Comment:
   > It seems that the String.format is more readable here
   
   This optimization has been done from a performance perspective. The performance of String.format is relatively poor and triggers an array expansion, which can be referenced in issue #5804 . However, readability has been reduced.Performance enhancement should be considered as the first priority.



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


[GitHub] [rocketmq] codecov-commenter commented on pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870#issuecomment-1380601368

   # [Codecov](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#5870](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (60e0e53) into [develop](https://codecov.io/gh/apache/rocketmq/commit/5894332918e7158d6ff4cc35b126a1b82a1f6b0c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5894332) will **decrease** coverage by `0.08%`.
   > The diff coverage is `20.75%`.
   
   ```diff
   @@              Coverage Diff              @@
   ##             develop    #5870      +/-   ##
   =============================================
   - Coverage      42.48%   42.40%   -0.09%     
   - Complexity      8248     8283      +35     
   =============================================
     Files           1060     1066       +6     
     Lines          73473    73670     +197     
     Branches        9616     9629      +13     
   =============================================
   + Hits           31215    31239      +24     
   - Misses         38334    38476     +142     
   - Partials        3924     3955      +31     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...cketmq/broker/longpolling/NotificationRequest.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvbG9uZ3BvbGxpbmcvTm90aWZpY2F0aW9uUmVxdWVzdC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...broker/processor/AbstractSendMessageProcessor.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL0Fic3RyYWN0U2VuZE1lc3NhZ2VQcm9jZXNzb3IuamF2YQ==) | `33.22% <ø> (+0.50%)` | :arrow_up: |
   | [...ocketmq/broker/processor/PeekMessageProcessor.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL1BlZWtNZXNzYWdlUHJvY2Vzc29yLmphdmE=) | `3.22% <0.00%> (ø)` | |
   | [...he/rocketmq/broker/processor/PopReviveService.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL1BvcFJldml2ZVNlcnZpY2UuamF2YQ==) | `39.62% <0.00%> (ø)` | |
   | [...mq/client/impl/producer/DefaultMQProducerImpl.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9jbGllbnQvaW1wbC9wcm9kdWNlci9EZWZhdWx0TVFQcm9kdWNlckltcGwuamF2YQ==) | `46.17% <0.00%> (-0.25%)` | :arrow_down: |
   | [...org/apache/rocketmq/store/DefaultMessageStore.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL0RlZmF1bHRNZXNzYWdlU3RvcmUuamF2YQ==) | `52.91% <ø> (ø)` | |
   | [...a/org/apache/rocketmq/store/stats/BrokerStats.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3N0YXRzL0Jyb2tlclN0YXRzLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...cketmq/broker/processor/NotificationProcessor.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL05vdGlmaWNhdGlvblByb2Nlc3Nvci5qYXZh) | `10.16% <3.44%> (-0.74%)` | :arrow_down: |
   | [...pache/rocketmq/store/stats/BrokerStatsManager.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3RvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3JvY2tldG1xL3N0b3JlL3N0YXRzL0Jyb2tlclN0YXRzTWFuYWdlci5qYXZh) | `50.29% <53.84%> (-0.02%)` | :arrow_down: |
   | [...ker/processor/DefaultPullMessageResultHandler.java](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9yb2NrZXRtcS9icm9rZXIvcHJvY2Vzc29yL0RlZmF1bHRQdWxsTWVzc2FnZVJlc3VsdEhhbmRsZXIuamF2YQ==) | `38.46% <100.00%> (ø)` | |
   | ... and [45 more](https://codecov.io/gh/apache/rocketmq/pull/5870?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


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


[GitHub] [rocketmq] mxsm commented on a diff in pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
mxsm commented on code in PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870#discussion_r1067672501


##########
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java:
##########
@@ -695,16 +695,13 @@ private SendResult sendDefaultImpl(
             if (sendResult != null) {
                 return sendResult;
             }
+            StringBuilder info = new StringBuilder(300);
+            info.append("Send [").append(times).append("] times, still failed, cost [")
+                .append(System.currentTimeMillis() - beginTimestampFirst).append("]ms, Topic: ").append(msg.getTopic())
+                .append(", BrokersSent: ").append(Arrays.toString(brokersSent))
+                .append(FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED));

Review Comment:
   > It seems that the String.format is more readable here
   
   @RongtongJin This optimization has been done from a performance perspective. The performance of String.format is relatively poor and triggers an array expansion, which can be referenced in issue #5804 . However, readability has been reduced.Performance enhancement should be considered as the first priority.



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


[GitHub] [rocketmq] RongtongJin merged pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
RongtongJin merged PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870


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


[GitHub] [rocketmq] mxsm commented on a diff in pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
mxsm commented on code in PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870#discussion_r1067672501


##########
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java:
##########
@@ -695,16 +695,13 @@ private SendResult sendDefaultImpl(
             if (sendResult != null) {
                 return sendResult;
             }
+            StringBuilder info = new StringBuilder(300);
+            info.append("Send [").append(times).append("] times, still failed, cost [")
+                .append(System.currentTimeMillis() - beginTimestampFirst).append("]ms, Topic: ").append(msg.getTopic())
+                .append(", BrokersSent: ").append(Arrays.toString(brokersSent))
+                .append(FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED));

Review Comment:
   > It seems that the String.format is more readable here
   
   @RongtongJin This optimization has been done from a performance perspective. The performance of String.format is relatively poor and triggers an array expansion, which can be referenced in issue #5804 . However, readability has been reduced.Performance enhancement should be considered as the first priority.  Or Add a comment that enhances readability.



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


[GitHub] [rocketmq] Oliverwqcwrw commented on a diff in pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
Oliverwqcwrw commented on code in PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870#discussion_r1067959835


##########
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java:
##########
@@ -695,16 +695,13 @@ private SendResult sendDefaultImpl(
             if (sendResult != null) {
                 return sendResult;
             }
+            StringBuilder info = new StringBuilder(300);
+            info.append("Send [").append(times).append("] times, still failed, cost [")
+                .append(System.currentTimeMillis() - beginTimestampFirst).append("]ms, Topic: ").append(msg.getTopic())
+                .append(", BrokersSent: ").append(Arrays.toString(brokersSent))
+                .append(FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED));

Review Comment:
   IMO, these transitions are all in the exception scene,
   
   it will lost a little performance when in the little scene,
   
   so  we can choose the readability when in this scene.



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


[GitHub] [rocketmq] xdkxlk commented on a diff in pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
xdkxlk commented on code in PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870#discussion_r1068055068


##########
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java:
##########
@@ -695,16 +695,13 @@ private SendResult sendDefaultImpl(
             if (sendResult != null) {
                 return sendResult;
             }
+            StringBuilder info = new StringBuilder(300);
+            info.append("Send [").append(times).append("] times, still failed, cost [")
+                .append(System.currentTimeMillis() - beginTimestampFirst).append("]ms, Topic: ").append(msg.getTopic())
+                .append(", BrokersSent: ").append(Arrays.toString(brokersSent))
+                .append(FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED));

Review Comment:
   Use MoreObjects.toStringHelper of guava or ToStringBuilder of commons-lang is more readable



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


[GitHub] [rocketmq] RongtongJin commented on a diff in pull request #5870: [ISSUE #5859]Optimize String#format in DefaultMQProducerImpl

Posted by GitBox <gi...@apache.org>.
RongtongJin commented on code in PR #5870:
URL: https://github.com/apache/rocketmq/pull/5870#discussion_r1067647165


##########
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java:
##########
@@ -695,16 +695,13 @@ private SendResult sendDefaultImpl(
             if (sendResult != null) {
                 return sendResult;
             }
+            StringBuilder info = new StringBuilder(300);
+            info.append("Send [").append(times).append("] times, still failed, cost [")
+                .append(System.currentTimeMillis() - beginTimestampFirst).append("]ms, Topic: ").append(msg.getTopic())
+                .append(", BrokersSent: ").append(Arrays.toString(brokersSent))
+                .append(FAQUrl.suggestTodo(FAQUrl.SEND_MSG_FAILED));

Review Comment:
   It seems that the String.format is more readable here



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