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 (更多上下文/截图)

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 (更多上下文/截图)
