You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/09/08 03:24:28 UTC
[GitHub] [dubbo-go] watermelo commented on a change in pull request #739: Imp: Improve map access concurrency
watermelo commented on a change in pull request #739:
URL: https://github.com/apache/dubbo-go/pull/739#discussion_r484628838
##########
File path: protocol/rpc_status.go
##########
@@ -98,7 +98,10 @@ func (rpc *RPCStatus) GetSuccessiveRequestFailureCount() int32 {
// GetURLStatus get URL RPC status.
func GetURLStatus(url common.URL) *RPCStatus {
- rpcStatus, _ := serviceStatistic.LoadOrStore(url.Key(), &RPCStatus{})
+ rpcStatus, found := serviceStatistic.Load(url.Key())
Review comment:
It seems to have higher performance, go version is 1.13.
```go
func BenchmarkStore(b *testing.B) {
for i := 0; i < b.N; i++ {
_, found := methodStatistics.Load("test")
if !found {
_, _ = methodStatistics.LoadOrStore("test", &RPCStatus{})
}
}
}
func BenchmarkLoadOrStore(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = methodStatistics.LoadOrStore("test", &RPCStatus{})
}
}
BenchmarkStore-4 23008020 48.4 ns/op 0 B/op 0 allocs/op
BenchmarkLoadOrStore-4 10381435 102 ns/op 80 B/op 1 allocs/op
PASS
```
----------------------------------------------------------------
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.
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