You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "shawnh2 (via GitHub)" <gi...@apache.org> on 2023/03/30 14:38:00 UTC

[GitHub] [dubbo-go-pixiu] shawnh2 opened a new pull request, #554: Add Maglev hashing LB algorithm

shawnh2 opened a new pull request, #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554

   - add Maglev hash load balancing algorithm
   - rename original consistent hash to ring-hash


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1161305778


##########
pixiu/pkg/cluster/loadbalancer/maglev/maglev_hash.go:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package maglev
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/cluster/loadbalancer"
+	consistent "github.com/apache/dubbo-go-pixiu/pixiu/pkg/cluster/loadbalancer/ringhash"
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+)
+
+func init() {
+	loadbalancer.RegisterLoadBalancer(model.LoadBalanceMaglevHashing, MaglevHash{})
+	loadbalancer.RegisterConsistentHashInit(model.LoadBalanceMaglevHashing, NewMaglevHash)
+}
+
+func NewMaglevHash(config model.ConsistentHash, endpoints []*model.Endpoint) model.LbConsistentHash {
+	hosts := make([]string, len(endpoints))
+	for i, endpoint := range endpoints {
+		hosts[i] = endpoint.GetHost()
+	}
+
+	h, err := NewLookUpTable(config.MaglevTableSize, hosts)
+	if err == nil {
+		h.Populate()
+		return h
+	}
+
+	logger.Debugf("[dubbo-go-pixiu] maglev hash load balancing error cause: %v, using ring hash instead", err)
+	return consistent.NewRingHash(config, endpoints)
+}
+
+type MaglevHash struct{}
+
+func (m MaglevHash) Handler(c *model.ClusterConfig, policy model.LbPolicy) *model.Endpoint {
+	dst, err := c.ConsistentHash.Hash.Get(policy.GenerateHash())
+	if err != nil {

Review Comment:
   added



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] codecov-commenter commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1491329804

   ## [Codecov](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554?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 [#554](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d58e4f8) into [develop](https://codecov.io/gh/apache/dubbo-go-pixiu/commit/9b15a87505a183487261876d59224f5ab718cdd1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9b15a87) will **increase** coverage by `0.09%`.
   > The diff coverage is `87.84%`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           develop     #554      +/-   ##
   ===========================================
   + Coverage    54.72%   54.82%   +0.09%     
   ===========================================
     Files          667      669       +2     
     Lines        78143    78313     +170     
   ===========================================
   + Hits         42762    42933     +171     
     Misses       31726    31726              
   + Partials      3655     3654       -1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [pixiu/pkg/server/cluster\_manager.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGl4aXUvcGtnL3NlcnZlci9jbHVzdGVyX21hbmFnZXIuZ28=) | `36.84% <0.00%> (ø)` | |
   | [...xiu/pkg/cluster/loadbalancer/ringhash/ring\_hash.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGl4aXUvcGtnL2NsdXN0ZXIvbG9hZGJhbGFuY2VyL3JpbmdoYXNoL3JpbmdfaGFzaC5nbw==) | `74.07% <74.07%> (ø)` | |
   | [...xiu/pkg/cluster/loadbalancer/maglev/permutation.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGl4aXUvcGtnL2NsdXN0ZXIvbG9hZGJhbGFuY2VyL21hZ2xldi9wZXJtdXRhdGlvbi5nbw==) | `92.70% <92.70%> (ø)` | |
   | [...xiu/pkg/cluster/loadbalancer/maglev/maglev\_hash.go](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGl4aXUvcGtnL2NsdXN0ZXIvbG9hZGJhbGFuY2VyL21hZ2xldi9tYWdsZXZfaGFzaC5nbw==) | `76.19% <100.00%> (ø)` | |
   
   ... and [19 files with indirect coverage changes](https://codecov.io/gh/apache/dubbo-go-pixiu/pull/554/indirect-changes?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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1162318739


##########
pixiu/pkg/cluster/loadbalancer/rand/load_balancer_rand.go:
##########
@@ -33,5 +33,5 @@ func init() {
 type Rand struct{}
 
 func (Rand) Handler(c *model.ClusterConfig, _ model.LbPolicy) *model.Endpoint {
-	return c.GetEndpoint(true)[rand.Intn(len(c.Endpoints)-1)]
+	return c.GetEndpoint(true)[rand.Intn(len(c.Endpoints))]

Review Comment:
   先 fix 了



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1158000700


##########
pixiu/pkg/cluster/loadbalancer/maglev/maglev_hash_test.go:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package maglev
+
+import (
+	"fmt"
+
+	std "net/http"
+	"strconv"
+	"testing"
+

Review Comment:
   solved



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1500318290

   > > 分配好像不均衡,result `map[1:6 2:2 3:4 4:5 5:3]`
   > 
   > maglev hash 算法要求的是 LookUpTable 的表长度(也就是其结构体内 size 字段的值)必须是个质数,这样可以保证均衡。
   > 
   > 但在目前的实现中,这一点我没有去保证,我来补充一下。
   
   fixed, @baerwang 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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] sonarcloud[bot] commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1490442452

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go-pixiu&pullRequest=554)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554) No Coverage information  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1158530701


##########
pixiu/pkg/cluster/loadbalancer/ringhash/ring_hash_test.go:
##########
@@ -19,7 +19,7 @@ package consistent
 
 import (
 	"fmt"
-	stdHttp "net/http"
+	std "net/http"

Review Comment:
   fixed



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] sonarcloud[bot] commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1500303506

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go-pixiu&pullRequest=554)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554) No Coverage information  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1161704158


##########
pixiu/pkg/cluster/loadbalancer/rand/load_balancer_rand.go:
##########
@@ -33,5 +33,5 @@ func init() {
 type Rand struct{}
 
 func (Rand) Handler(c *model.ClusterConfig, _ model.LbPolicy) *model.Endpoint {
-	return c.GetEndpoint(true)[rand.Intn(len(c.Endpoints)-1)]
+	return c.GetEndpoint(true)[rand.Intn(len(c.Endpoints))]

Review Comment:
   请问一下大佬这个操作会引发什么panic?因为根据目前的压测和随机范围来看,如果有5个节点,是只会随机到前四个上面的,最后一个接收不到任何请求。



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] baerwang commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "baerwang (via GitHub)" <gi...@apache.org>.
baerwang commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1158225995


##########
pixiu/pkg/cluster/loadbalancer/ringhash/ring_hash_test.go:
##########
@@ -19,7 +19,7 @@ package consistent
 
 import (
 	"fmt"
-	stdHttp "net/http"
+	std "net/http"

Review Comment:
   std change stdHttp



##########
pixiu/pkg/cluster/loadbalancer/maglev/permutation.go:
##########
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package maglev
+
+import (
+	"encoding/binary"
+	"errors"
+	"hash/crc32"
+	"math"
+	"sync"
+)
+
+import (
+	"golang.org/x/crypto/blake2b"
+	"golang.org/x/crypto/sha3"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
+)
+
+type permutation struct {
+	pos   []uint32
+	next  int
+	index int
+	hit   int
+}
+
+type LookUpTable struct {
+	slots        []string
+	permutations []*permutation
+	buckets      map[int]string
+	endpointNum  int
+	size         int
+	factor       int
+	sync.RWMutex
+}
+
+func NewLookUpTable(factor int, hosts []string) *LookUpTable {
+	if factor < 10 || factor > 1000 {
+		logger.Debugf("[dubbo-go-pixiu] The factor of Maglev load balancing should between 10 and 1000 "+
+			"but got %d instead. Setting factor to 100 by default.", factor)
+		factor = 100
+	}
+
+	buckets := make(map[int]string)

Review Comment:
   new map add cap



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] baerwang commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "baerwang (via GitHub)" <gi...@apache.org>.
baerwang commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1498494746

   分配好像不均衡,result `map[1:6 2:2 3:4 4:5 5:3]`
   
   ```go
   func TestMaglevHash(t *testing.T) {
   
   	nodeCount := 5
   
   	nodes := make([]*model.Endpoint, 0, nodeCount)
   
   	for i := 1; i <= nodeCount; i++ {
   		name := strconv.Itoa(i)
   		nodes = append(nodes, &model.Endpoint{ID: name, Name: name,
   			Address: model.SocketAddress{Address: "192.168.1." + name, Port: 1000 + i}})
   	}
   
   	cluster := &model.ClusterConfig{
   		Name:           "test-cluster",
   		Endpoints:      nodes,
   		LbStr:          model.LoadBalanceMaglevHashing,
   		ConsistentHash: model.ConsistentHash{ReplicaFactor: 10},
   	}
   	cluster.CreateConsistentHash()
   
   	var (
   		hashing = MaglevHash{}
   		path    string
   	)
   
   	record := make(map[string]int, 20)
   
   	for i := 1; i <= 20; i++ {
   		path = fmt.Sprintf("/pixiu?total=%d", i)
   		handler := hashing.Handler(cluster, &http.HttpContext{Request: &stdHttp.Request{Method: stdHttp.MethodGet, RequestURI: path}})
   		if _, ok := record[handler.ID]; ok {
   			record[handler.ID]++
   			continue
   		}
   		record[handler.ID] = 1
   	}
   
   	t.Log(record)
   }
   ```
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] AlexStocks merged pull request #554: Add Maglev hashing LB algorithm

Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks merged PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1158539427


##########
pixiu/pkg/cluster/loadbalancer/maglev/permutation.go:
##########
@@ -0,0 +1,279 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package maglev
+
+import (
+	"encoding/binary"
+	"errors"
+	"hash/crc32"
+	"math"
+	"sync"
+)
+
+import (
+	"golang.org/x/crypto/blake2b"
+	"golang.org/x/crypto/sha3"
+)
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
+)
+
+type permutation struct {
+	pos   []uint32
+	next  int
+	index int
+	hit   int
+}
+
+type LookUpTable struct {
+	slots        []string
+	permutations []*permutation
+	buckets      map[int]string
+	endpointNum  int
+	size         int
+	factor       int
+	sync.RWMutex
+}
+
+func NewLookUpTable(factor int, hosts []string) *LookUpTable {
+	if factor < 10 || factor > 1000 {
+		logger.Debugf("[dubbo-go-pixiu] The factor of Maglev load balancing should between 10 and 1000 "+
+			"but got %d instead. Setting factor to 100 by default.", factor)
+		factor = 100
+	}
+
+	buckets := make(map[int]string)

Review Comment:
   fixed



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] mark4z commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "mark4z (via GitHub)" <gi...@apache.org>.
mark4z commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1501047678

   Using a simple benchmark testing tool to test the effect of load balancing, 1 of 5 endpoints always can not receive requests, and starts to get 503 frequently after a period of time.
   
   <img width="532" alt="image" src="https://user-images.githubusercontent.com/36187602/230756506-afb96b93-9ba7-4c2f-8616-9457b5e97653.png">
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] baerwang commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "baerwang (via GitHub)" <gi...@apache.org>.
baerwang commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1161663027


##########
pixiu/pkg/cluster/loadbalancer/rand/load_balancer_rand.go:
##########
@@ -33,5 +33,5 @@ func init() {
 type Rand struct{}
 
 func (Rand) Handler(c *model.ClusterConfig, _ model.LbPolicy) *model.Endpoint {
-	return c.GetEndpoint(true)[rand.Intn(len(c.Endpoints)-1)]
+	return c.GetEndpoint(true)[rand.Intn(len(c.Endpoints))]

Review Comment:
   这个操作会造成panic,请不要更改这个代码



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1501130937

   > Using a simple benchmark testing tool https://github.com/mark4z/hey to test the effect of load balancing, 1 of 5 endpoints always can not receive requests, and starts to get 503 frequently after a period of time.
   
   此次测试,由于该版代码并没有在 pluginregistry 中注册,所以压测的实质上是默认的 rand 策略。至于为什么总有一个节点接收不到请求,我看了一下是 rand 的随机区间设置的有问题,目前已更正。


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1501155390

   new benchmark result on Maglev hash, using same config as https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1501047724
   
   <img width="609" alt="image" src="https://user-images.githubusercontent.com/40317966/230782065-dccb8239-4ef4-455a-a021-b302722671c6.png">
   
   endpoints 1 recv: 5847
   endpoints 2 recv: 5840
   endpoints 3 recv: 5770
   endpoints 4 recv: 5782
   endpoints 5 recv: 5675


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] shawnh2 commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "shawnh2 (via GitHub)" <gi...@apache.org>.
shawnh2 commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1498772806

   > 分配好像不均衡,result `map[1:6 2:2 3:4 4:5 5:3]`
   
   maglev hash 算法要求的是 LookUpTable 的表长度(也就是其结构体内 size 字段的值)必须是个质数,这样可以保证均衡。
   
   但在目前的实现中,这一点我没有去保证,我来补充一下。
   
   当然,还有一点,就是目前的 hash 函数不是一个随机 hash,这就导致上述代码每次运行结果都一样,这个问题我也解决一下。


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] sonarcloud[bot] commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1497516878

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go-pixiu&pullRequest=554)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554) No Coverage information  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] mark4z commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "mark4z (via GitHub)" <gi...@apache.org>.
mark4z commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1161216113


##########
pixiu/pkg/cluster/loadbalancer/maglev/maglev_hash.go:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package maglev
+
+import (
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/cluster/loadbalancer"
+	consistent "github.com/apache/dubbo-go-pixiu/pixiu/pkg/cluster/loadbalancer/ringhash"
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
+	"github.com/apache/dubbo-go-pixiu/pixiu/pkg/model"
+)
+
+func init() {
+	loadbalancer.RegisterLoadBalancer(model.LoadBalanceMaglevHashing, MaglevHash{})
+	loadbalancer.RegisterConsistentHashInit(model.LoadBalanceMaglevHashing, NewMaglevHash)
+}
+
+func NewMaglevHash(config model.ConsistentHash, endpoints []*model.Endpoint) model.LbConsistentHash {
+	hosts := make([]string, len(endpoints))
+	for i, endpoint := range endpoints {
+		hosts[i] = endpoint.GetHost()
+	}
+
+	h, err := NewLookUpTable(config.MaglevTableSize, hosts)
+	if err == nil {
+		h.Populate()
+		return h
+	}
+
+	logger.Debugf("[dubbo-go-pixiu] maglev hash load balancing error cause: %v, using ring hash instead", err)
+	return consistent.NewRingHash(config, endpoints)
+}
+
+type MaglevHash struct{}
+
+func (m MaglevHash) Handler(c *model.ClusterConfig, policy model.LbPolicy) *model.Endpoint {
+	dst, err := c.ConsistentHash.Hash.Get(policy.GenerateHash())
+	if err != nil {

Review Comment:
   print log?



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] sonarcloud[bot] commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1496895708

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go-pixiu&pullRequest=554)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554) No Coverage information  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] sonarcloud[bot] commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1501157276

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go-pixiu&pullRequest=554)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554) No Coverage information  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] baerwang commented on a diff in pull request #554: Add Maglev hashing LB algorithm

Posted by "baerwang (via GitHub)" <gi...@apache.org>.
baerwang commented on code in PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#discussion_r1155219300


##########
pixiu/pkg/cluster/loadbalancer/maglev/maglev_hash_test.go:
##########
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package maglev
+
+import (
+	"fmt"
+
+	std "net/http"
+	"strconv"
+	"testing"
+

Review Comment:
   go get -u github.com/dubbogo/tools/cmd/imports-formatter
   
   按照这个工具,将import格式化下



-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] mark4z commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "mark4z (via GitHub)" <gi...@apache.org>.
mark4z commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1501047724

   ```yaml
   ---
   static_resources:
     listeners:
       - name: "net/http"
         protocol_type: "HTTP"
         address:
           socket_address:
             address: "0.0.0.0"
             port: 8888
         filter_chains:
           filters:
             - name: dgp.filter.httpconnectionmanager
               config:
                 route_config:
                   routes:
                     - match:
                         prefix: "/count"
                       route:
                         cluster: "count"
                         cluster_not_found_response_code: 505
                 http_filters:
                   - name: dgp.filter.http.httpproxy
                     config:
         config:
           idle_timeout: 5s
           read_timeout: 5s
           write_timeout: 5s
     clusters:
       - name: "count"
         lb_policy: "MaglevHashing"
         endpoints:
           - id: 1
             socket_address:
               address: localhost
               port: 8080
           - id: 2
             socket_address:
               address: localhost
               port: 8081
           - id: 3
             socket_address:
               address: localhost
               port: 8082
           - id: 4
             socket_address:
               address: localhost
               port: 8083
           - id: 5
             socket_address:
               address: localhost
               port: 8084
     shutdown_config:
       timeout: "60s"
       step_timeout: "10s"
       reject_policy: "immediacy"
   ```


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] sonarcloud[bot] commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1497496670

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go-pixiu&pullRequest=554)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554) No Coverage information  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] sonarcloud[bot] commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1502712599

   Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_dubbo-go-pixiu&pullRequest=554)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_dubbo-go-pixiu&pullRequest=554&resolved=false&types=CODE_SMELL)
   
   [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554) No Coverage information  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache_dubbo-go-pixiu&pullRequest=554&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-pixiu] mark4z commented on pull request #554: Add Maglev hashing LB algorithm

Posted by "mark4z (via GitHub)" <gi...@apache.org>.
mark4z commented on PR #554:
URL: https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1510063921

   > new benchmark result on Maglev hash, using same config as [#554 (comment)](https://github.com/apache/dubbo-go-pixiu/pull/554#issuecomment-1501047724)
   > 
   > <img alt="image" width="609" src="https://user-images.githubusercontent.com/40317966/230782065-dccb8239-4ef4-455a-a021-b302722671c6.png">
   > 
   > endpoints 1 recv: 5847 endpoints 2 recv: 5840 endpoints 3 recv: 5770 endpoints 4 recv: 5782 endpoints 5 recv: 5675
   
   nice job


-- 
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: notifications-unsubscribe@dubbo.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org