You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "dongjiang1989 (via GitHub)" <gi...@apache.org> on 2024/02/29 07:53:22 UTC
[PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
dongjiang1989 opened a new pull request, #2599:
URL: https://github.com/apache/dubbo-go/pull/2599
## Describe the solution you'd like
support weighted random algorithm with preprocessing time complexity O(n) and selection time complexity O(1), called the [alias method](https://en.wikipedia.org/wiki/Alias_method).
ref: https://github.com/cloudwego/kitex/issues/1184
## Additional context
Alias Method:
- https://en.wikipedia.org/wiki/Alias_method
- http://www.keithschwarz.com/darts-dice-coins/
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "justxuewei (via GitHub)" <gi...@apache.org>.
justxuewei commented on code in PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#discussion_r1507165033
##########
cluster/loadbalance/loadbalance_benchmarks_test.go:
##########
@@ -29,6 +29,7 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/ringhash"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/roundrobin"
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/weightedrandomwithaliasmethod"
Review Comment:
IMHO, the name is too long which reduces readabilty signaficantly. How about `aliasmethod`?
##########
cluster/loadbalance/weightedrandomwithaliasmethod/doc.go:
##########
@@ -0,0 +1,19 @@
+/*
+ * 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 wram implements alias-method algorithm load balance strategy.
+package wram // weighted random with alias-method algorithm
Review Comment:
Don't forget changing this as well.
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "dongjiang1989 (via GitHub)" <gi...@apache.org>.
dongjiang1989 commented on code in PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#discussion_r1510500656
##########
cluster/loadbalance/weightedrandomwithaliasmethod/doc.go:
##########
@@ -0,0 +1,19 @@
+/*
+ * 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 wram implements alias-method algorithm load balance strategy.
+package wram // weighted random with alias-method algorithm
Review Comment:
Changed it.
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "dongjiang1989 (via GitHub)" <gi...@apache.org>.
dongjiang1989 commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1970650918
> Thanks for your contributions. I have a suggest regarding the name of this lb.
Great! changed it.
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "dongjiang1989 (via GitHub)" <gi...@apache.org>.
dongjiang1989 commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1970594488
loadbalance benchmarks test.
```
goos: darwin
goarch: amd64
pkg: dubbo.apache.org/dubbo-go/v3/cluster/loadbalance
cpu: VirtualApple @ 2.50GHz
BenchmarkRoudrobinLoadbalance-8 6272 171457 ns/op 88098 B/op 2555 allocs/op
BenchmarkLeastativeLoadbalance-8 7362 161141 ns/op 81882 B/op 2043 allocs/op
BenchmarkConsistenthashingLoadbalance-8 52753 22945 ns/op 3440 B/op 267 allocs/op
BenchmarkP2CLoadbalance-8 2516283 481.6 ns/op 472 B/op 10 allocs/op
BenchmarkInterleavedWeightedRoundRobinLoadbalance-8 19672 61067 ns/op 45312 B/op 1027 allocs/op
BenchmarkRandomLoadbalance-8 23068 52368 ns/op 38992 B/op 767 allocs/op
BenchmarkWeightedRandomWithAliasMethodLoadbalance-8 22147 54087 ns/op 49232 B/op 772 allocs/op
PASS
ok dubbo.apache.org/dubbo-go/v3/cluster/loadbalance 11.508s
```
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "justxuewei (via GitHub)" <gi...@apache.org>.
justxuewei closed pull request #2599: feat(lb): add loadbalancer with alias-method algorithm
URL: https://github.com/apache/dubbo-go/pull/2599
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "dongjiang1989 (via GitHub)" <gi...@apache.org>.
dongjiang1989 commented on code in PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#discussion_r1507198602
##########
cluster/loadbalance/loadbalance_benchmarks_test.go:
##########
@@ -29,6 +29,7 @@ import (
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/random"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/ringhash"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/roundrobin"
+ _ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance/weightedrandomwithaliasmethod"
Review Comment:
changed it.
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "justxuewei (via GitHub)" <gi...@apache.org>.
justxuewei commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1975655624
I'd like to close this PR due to license issues.
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "dongjiang1989 (via GitHub)" <gi...@apache.org>.
dongjiang1989 commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1970597876
@justxuewei 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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1972186826
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 No data about Coverage
 [2.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599)
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1972755191
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 No data about Coverage
 [2.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599)
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1970594712
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 No data about Coverage
 [2.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599)
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1970651040
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=2599&resolved=false&inNewCodePeriod=true)
 No data about Coverage
 [2.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=2599&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=2599)
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1970616652
## [Codecov](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: Patch coverage is `90.32258%` with `6 lines` in your changes are missing coverage. Please review.
> Project coverage is 47.66%. Comparing base [(`8efb9ea`)](https://app.codecov.io/gh/apache/dubbo-go/commit/8efb9ea902733e0fd7d947df13e0091c07b820ea?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`1359346`)](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
> :exclamation: Current head 1359346 differs from pull request most recent head 898e7d0. Consider uploading reports for the commit 898e7d0 to get more accurate results
| [Files](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../loadbalance/weightedrandomwithaliasmethod/wram.go](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS93ZWlnaHRlZHJhbmRvbXdpdGhhbGlhc21ldGhvZC93cmFtLmdv) | 92.00% | [3 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...lance/weightedrandomwithaliasmethod/loadbalance.go](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y2x1c3Rlci9sb2FkYmFsYW5jZS93ZWlnaHRlZHJhbmRvbXdpdGhhbGlhc21ldGhvZC9sb2FkYmFsYW5jZS5nbw==) | 83.33% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #2599 +/- ##
==========================================
- Coverage 47.68% 47.66% -0.02%
==========================================
Files 339 341 +2
Lines 24929 24991 +62
==========================================
+ Hits 11887 11912 +25
- Misses 11891 11928 +37
Partials 1151 1151
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/dubbo-go/pull/2599?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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
Re: [PR] feat(lb): add loadbalancer with alias-method algorithm [dubbo-go]
Posted by "dongjiang1989 (via GitHub)" <gi...@apache.org>.
dongjiang1989 commented on PR #2599:
URL: https://github.com/apache/dubbo-go/pull/2599#issuecomment-1975813291
> I'd like to close this PR due to license issues.
Add licence to `NOTICE` file?
--
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