You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2020/07/29 07:22:56 UTC

[GitHub] [incubator-brpc] GOGOYAO opened a new issue #1190: bthread::Mutex的内存占用远大于std::mutex

GOGOYAO opened a new issue #1190:
URL: https://github.com/apache/incubator-brpc/issues/1190


   **Describe the bug (描述bug)**
   std::vector<bthread::Mutex> locks_(1000000)
   std::vector<std::mutex> locks_(1000000)
   top查看,前者占用 VIRT:212M,RES:84612;后者占用 VIRT:66624,RES:7120
   
   这个内存使用的差距有点大(RES是10倍关系)哦,简单看了下源码,感觉应该没有那么大差距才对?
   
   **To Reproduce (复现方法)**
   随意写个main函数就可以了
   
   **Expected behavior (期望行为)**
   差距没有量级的差距
   
   **Versions (各种版本)**
   OS: centos7
   Compiler: gcc 8
   brpc: master (11da9c8cbdc2ec8c0da728aedb4ed906717d6e0f)
   protobuf: 3.11
   
   **Additional context/screenshots (更多上下文/截图)**
   
   


----------------------------------------------------------------
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: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] GOGOYAO commented on issue #1190: bthread::Mutex的内存占用远大于std::mutex

Posted by GitBox <gi...@apache.org>.
GOGOYAO commented on issue #1190:
URL: https://github.com/apache/incubator-brpc/issues/1190#issuecomment-675225869


   > 什么场景需要用到这么多mutex实例?
   
   在braft 做 multi raft的时候,每个分片(一个分片一个raft group)都放了一个条带锁。最开始放得比较大(10000个),分片多了就导致内存爆了。


----------------------------------------------------------------
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: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] GOGOYAO edited a comment on issue #1190: bthread::Mutex的内存占用远大于std::mutex

Posted by GitBox <gi...@apache.org>.
GOGOYAO edited a comment on issue #1190:
URL: https://github.com/apache/incubator-brpc/issues/1190#issuecomment-675225869


   > 什么场景需要用到这么多mutex实例?
   
   在braft 做 multi raft的时候,每个分片(一个分片一个raft group)都放了一个条带锁。最开始放得比较大(10000个),分片多了就导致内存爆了,现在已经改成100了。因此想问下这个问题。


----------------------------------------------------------------
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: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] GOGOYAO commented on issue #1190: bthread::Mutex的内存占用远大于std::mutex

Posted by GitBox <gi...@apache.org>.
GOGOYAO commented on issue #1190:
URL: https://github.com/apache/incubator-brpc/issues/1190#issuecomment-677512297


   > 我看你提供的数据10000实例的时候,虚拟内存使用量也就2M吧?这个对于您的场景来说很大是吧
   
   分片多了就不行了。这个问题是在有个测试case发现的,当时调成了1000000。多几个分片就挂了


----------------------------------------------------------------
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: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on issue #1190: bthread::Mutex的内存占用远大于std::mutex

Posted by GitBox <gi...@apache.org>.
gydong commented on issue #1190:
URL: https://github.com/apache/incubator-brpc/issues/1190#issuecomment-677495844


   我看你提供的数据10000实例的时候,虚拟内存使用量也就2M吧?这个对于您的场景来说很大是吧


----------------------------------------------------------------
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: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on issue #1190: bthread::Mutex的内存占用远大于std::mutex

Posted by GitBox <gi...@apache.org>.
gydong commented on issue #1190:
URL: https://github.com/apache/incubator-brpc/issues/1190#issuecomment-675186074


   什么场景需要用到这么多mutex实例?


----------------------------------------------------------------
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: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org