You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/06/24 12:24:54 UTC

[GitHub] [servicecomb-service-center] DFSOrange opened a new pull request #1070: cache use concurrentmap

DFSOrange opened a new pull request #1070:
URL: https://github.com/apache/servicecomb-service-center/pull/1070


   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `go build` `go test` `go fmt` `go vet` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
    - [ ] Never comment source code, delete it.
    - [ ] UT should has "context, subject, expected result" result as test case name, when you call t.Run().
   ---
   


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



[GitHub] [servicecomb-service-center] DFSOrange commented on a change in pull request #1070: cache use concurrentmap

Posted by GitBox <gi...@apache.org>.
DFSOrange commented on a change in pull request #1070:
URL: https://github.com/apache/servicecomb-service-center/pull/1070#discussion_r658541136



##########
File path: datasource/mongo/sd/service_cache.go
##########
@@ -131,10 +160,17 @@ func (s *serviceStore) isValueNotUpdated(value interface{}, newValue interface{}
 	return reflect.DeepEqual(newService, oldService)
 }
 
-func genServiceID(svc model.Service) string {
+func ServiceIDIndex(data interface{}) string {
+	svc := data.(model.Service)
 	return svc.Service.ServiceId

Review comment:
       > 生成serviceId的索引也得是{domain}/{project}/{serviceId}的形式,不然会出现多域之间serviceId相同的情况,请求中serviceId是可以用户指定的
   
   现在serviceid在mongodb中是唯一索引,如果支持的话,还需要取消这个了




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



[GitHub] [servicecomb-service-center] DFSOrange commented on a change in pull request #1070: cache use concurrentmap

Posted by GitBox <gi...@apache.org>.
DFSOrange commented on a change in pull request #1070:
URL: https://github.com/apache/servicecomb-service-center/pull/1070#discussion_r658425986



##########
File path: datasource/mongo/sd/dep_cache.go
##########
@@ -23,25 +23,31 @@ import (
 
 	"github.com/apache/servicecomb-service-center/datasource/mongo/client/model"
 	"github.com/apache/servicecomb-service-center/datasource/sdcommon"
+	cmap "github.com/orcaman/concurrent-map"
 	"go.mongodb.org/mongo-driver/bson"
 )
 
 type depStore struct {
-	dirty      bool
-	d          *DocStore
-	indexCache *IndexCache
+	dirty bool
+	// the key is documentID, is value is mongo document.
+	concurrentMap cmap.ConcurrentMap

Review comment:
       > 为何不用sync.Map
   
   主要有两个原因:
   1. [官方文档](https://golang.org/pkg/sync/#Map)介绍sync.map主要适用于两个场景1.key写入一次而读多次2.多个goroutine读写不相交的键值对,在实例服务变化频繁场景下不满足以上两个约束
   2. concurrentmap使用分片hash,sync.mapz是两层map(read+dirty),理论性能前者更好




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



[GitHub] [servicecomb-service-center] fuziye01 commented on a change in pull request #1070: cache use concurrentmap

Posted by GitBox <gi...@apache.org>.
fuziye01 commented on a change in pull request #1070:
URL: https://github.com/apache/servicecomb-service-center/pull/1070#discussion_r657950334



##########
File path: datasource/mongo/sd/service_cache.go
##########
@@ -131,10 +160,17 @@ func (s *serviceStore) isValueNotUpdated(value interface{}, newValue interface{}
 	return reflect.DeepEqual(newService, oldService)
 }
 
-func genServiceID(svc model.Service) string {
+func ServiceIDIndex(data interface{}) string {
+	svc := data.(model.Service)
 	return svc.Service.ServiceId

Review comment:
       生成serviceId的索引也得是{domain}/{project}/{serviceId}的形式,不然会出现多域之间serviceId相同的情况,请求中serviceId是可以用户指定的




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



[GitHub] [servicecomb-service-center] robotLJW merged pull request #1070: cache use concurrentmap

Posted by GitBox <gi...@apache.org>.
robotLJW merged pull request #1070:
URL: https://github.com/apache/servicecomb-service-center/pull/1070


   


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

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



[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #1070: cache use concurrentmap

Posted by GitBox <gi...@apache.org>.
tianxiaoliang commented on a change in pull request #1070:
URL: https://github.com/apache/servicecomb-service-center/pull/1070#discussion_r658394255



##########
File path: datasource/mongo/sd/dep_cache.go
##########
@@ -23,25 +23,31 @@ import (
 
 	"github.com/apache/servicecomb-service-center/datasource/mongo/client/model"
 	"github.com/apache/servicecomb-service-center/datasource/sdcommon"
+	cmap "github.com/orcaman/concurrent-map"
 	"go.mongodb.org/mongo-driver/bson"
 )
 
 type depStore struct {
-	dirty      bool
-	d          *DocStore
-	indexCache *IndexCache
+	dirty bool
+	// the key is documentID, is value is mongo document.
+	concurrentMap cmap.ConcurrentMap

Review comment:
       为何不用sync.Map




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