You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/12/07 12:32:11 UTC

[GitHub] [pulsar] AnonHxy opened a new pull request, #18800: [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel

AnonHxy opened a new pull request, #18800:
URL: https://github.com/apache/pulsar/pull/18800

   ### Motivation
   
   For most case, consumer in `currentRoundRobinIndex` should be available,  so we could avoid some scan actions  by checking `currentRRConsumer` available first.
   
   ### Modifications
   
   Fast return if validalbe when getNextConsumerFromSameOrLowerLevel
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: <!-- ENTER URL HERE -->
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->
   


-- 
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@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] AnonHxy commented on pull request #18800: [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel

Posted by GitBox <gi...@apache.org>.
AnonHxy commented on PR #18800:
URL: https://github.com/apache/pulsar/pull/18800#issuecomment-1343713971

   @Jason918 @HQebupt @codelipenghui @aloyszhang PTAL


-- 
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@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] Jason918 commented on a diff in pull request #18800: [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel

Posted by GitBox <gi...@apache.org>.
Jason918 commented on code in PR #18800:
URL: https://github.com/apache/pulsar/pull/18800#discussion_r1044144655


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java:
##########
@@ -189,10 +189,14 @@ private int getConsumerFromHigherPriority(int targetPriority) {
      * @return
      */
     private int getNextConsumerFromSameOrLowerLevel(int currentRoundRobinIndex) {
+        Consumer currentRRConsumer = consumerList.get(currentRoundRobinIndex);
+        if (isConsumerAvailable(currentRRConsumer)) {

Review Comment:
   It seems there is not much performance improvement. It's logically the same as it returns in the first do loop, right?
   So it's more like making the code more clear? 
   



-- 
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@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] AnonHxy commented on a diff in pull request #18800: [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel

Posted by GitBox <gi...@apache.org>.
AnonHxy commented on code in PR #18800:
URL: https://github.com/apache/pulsar/pull/18800#discussion_r1044182184


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractDispatcherMultipleConsumers.java:
##########
@@ -189,10 +189,14 @@ private int getConsumerFromHigherPriority(int targetPriority) {
      * @return
      */
     private int getNextConsumerFromSameOrLowerLevel(int currentRoundRobinIndex) {
+        Consumer currentRRConsumer = consumerList.get(currentRoundRobinIndex);
+        if (isConsumerAvailable(currentRRConsumer)) {

Review Comment:
   Yes. This will make the code more clear with minor performance improvement by avoiding the first time check in the loop @Jason918 



-- 
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@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] codecov-commenter commented on pull request #18800: [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel

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

   # [Codecov](https://codecov.io/gh/apache/pulsar/pull/18800?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 [#18800](https://codecov.io/gh/apache/pulsar/pull/18800?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ea922e8) into [master](https://codecov.io/gh/apache/pulsar/commit/3e18974f0bada394b3a87915e0589d1cd0e1ec17?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3e18974) will **decrease** coverage by `8.42%`.
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/pulsar/pull/18800/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/pulsar/pull/18800?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #18800      +/-   ##
   ============================================
   - Coverage     45.53%   37.10%   -8.43%     
   + Complexity    10220     1970    -8250     
   ============================================
     Files           703      209     -494     
     Lines         68797    14425   -54372     
     Branches       7374     1574    -5800     
   ============================================
   - Hits          31329     5353   -25976     
   + Misses        33881     8487   -25394     
   + Partials       3587      585    -3002     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `37.10% <ø> (-8.43%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/18800?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...he/pulsar/client/impl/MultiTopicsConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL011bHRpVG9waWNzQ29uc3VtZXJJbXBsLmphdmE=) | `22.86% <0.00%> (-0.12%)` | :arrow_down: |
   | [...r/service/AbstractDispatcherMultipleConsumers.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL0Fic3RyYWN0RGlzcGF0Y2hlck11bHRpcGxlQ29uc3VtZXJzLmphdmE=) | | |
   | [...ava/org/apache/pulsar/utils/StatsOutputStream.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL3V0aWxzL1N0YXRzT3V0cHV0U3RyZWFtLmphdmE=) | | |
   | [.../pulsar/broker/service/persistent/SystemTopic.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3BlcnNpc3RlbnQvU3lzdGVtVG9waWMuamF2YQ==) | | |
   | [...keeper/mledger/impl/ReadOnlyManagedLedgerImpl.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWFuYWdlZC1sZWRnZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2Jvb2trZWVwZXIvbWxlZGdlci9pbXBsL1JlYWRPbmx5TWFuYWdlZExlZGdlckltcGwuamF2YQ==) | | |
   | [.../metadata/v2/TransactionBufferSnapshotIndexes.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci90cmFuc2FjdGlvbi9idWZmZXIvbWV0YWRhdGEvdjIvVHJhbnNhY3Rpb25CdWZmZXJTbmFwc2hvdEluZGV4ZXMuamF2YQ==) | | |
   | [...org/apache/pulsar/broker/admin/impl/SinksBase.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL1NpbmtzQmFzZS5qYXZh) | | |
   | [...org/apache/pulsar/broker/web/WebExecutorStats.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci93ZWIvV2ViRXhlY3V0b3JTdGF0cy5qYXZh) | | |
   | [...ache/pulsar/broker/namespace/ServiceUnitUtils.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9uYW1lc3BhY2UvU2VydmljZVVuaXRVdGlscy5qYXZh) | | |
   | [...java/org/apache/pulsar/broker/rest/TopicsBase.java](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9yZXN0L1RvcGljc0Jhc2UuamF2YQ==) | | |
   | ... and [487 more](https://codecov.io/gh/apache/pulsar/pull/18800/diff?src=pr&el=tree-more&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@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] AnonHxy merged pull request #18800: [improve][broker] Fast return if validalbe when getNextConsumerFromSameOrLowerLevel

Posted by GitBox <gi...@apache.org>.
AnonHxy merged PR #18800:
URL: https://github.com/apache/pulsar/pull/18800


-- 
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@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org