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 2019/04/18 07:36:04 UTC

[GitHub] [incubator-brpc] lzueclipse commented on issue #734: 请问如何利用内置工具统计客户端程序cpu,内存的使用情况,以及发送的数据大小,及某个服务的网络数据通信的数据量?

lzueclipse commented on issue #734: 请问如何利用内置工具统计客户端程序cpu,内存的使用情况,以及发送的数据大小,及某个服务的网络数据通信的数据量?
URL: https://github.com/apache/incubator-brpc/issues/734#issuecomment-484390247
 
 
   我也在学习这块。今天大概看了下内存统计这块,应该有个小bug。
   
   
   246  
   247  class ProcMemoryReader {
   248  public:
   249      bool operator()(ProcMemory* stat) const {
   250          return read_proc_memory(*stat);
   251      };
   252      template <typename T, size_t offset>
   253      static T get_field(void*) {
   254          static int64_t pagesize = getpagesize();
   255          return *(T*)((char*)&CachedReader<ProcMemory>::get_value(
   256                           ProcMemoryReader()) + offset) * pagesize;
   257      }
   258  };
   
   我把get_field修改为, 多加个了括号,数据就正确了,请看看是这里的bug么?
   CentOS 7.6.1810上,gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC), 可以重现。
   我又去查了c++算符优先级,解引用大于乘法,似乎不加括号也行啊,搞不懂了。
   
   return  
   ( 
   *(T*)((char*)&CachedReader<ProcMemory>::get_value( ProcMemoryReader()) + offset) 
    ) * pagesize;

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org