zc08291161 opened a new issue, #2640:
URL: https://github.com/apache/brpc/issues/2640

   **Describe the bug (描述bug)**
   在brpc的统计页面上,很容易就发现bthread_worker_usage的值
   超过bthread_worker_count,理论上根据代码,bthread_worker_usage
   的值不会超过TaskGroup的个数,因为代码
   double TaskControl::get_cumulated_worker_time() {
       int64_t cputime_ns = 0;
       BAIDU_SCOPED_LOCK(_modify_group_mutex);
       const size_t ngroup = _ngroup.load(butil::memory_order_relaxed);
       for (size_t i = 0; i < ngroup; ++i) {
           if (_groups[i]) {
               cputime_ns += _groups[i]->_cumulated_cputime_ns;
           }
       }
       return cputime_ns / 1000000000.0;
   }
   
   这个函数是一秒钟统计一次,如果定时器完全准的话,一定不会超过ngroup的个数
   因此这个值是否强依赖定时器,因而不一定完全准确,是否应该将
    cputime_ns / 1000000000.0;
   更改为 cputime_ns / (real_elapse_time);其中real_elapse_time是这个函数两次
   调用的时间差。
   
   **To Reproduce (复现方法)**
   
   
   **Expected behavior (期望行为)**
   
   
   **Versions (各种版本)**
   OS:
   Compiler:
   brpc: 1.0.0
   protobuf:
   
   **Additional context/screenshots (更多上下文/截图)**
   
![image](https://github.com/apache/brpc/assets/34310804/0d5aa8eb-92bc-46b0-ba57-0065fed4553d)
   
   


-- 
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: dev-unsubscr...@brpc.apache.org.apache.org

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


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

Reply via email to