brpc
brpc copied to clipboard
Bugfix: bthread_worker_usage would be greater than bthread_worker_count
What problem does this PR solve?
Issue Number: resolve #1231 , resolve #2640 , resolve #2972
Problem Summary:
What is changed and the side effects?
Changed:
bthread_worker_usage should consist of _cumulated_cputime_ns and the CPU time of the task currently run by the worker.
Side effects:
-
Performance effects:
-
Breaking backward compatibility:
Check List:
- Please make sure your changes are compilable.
- When providing us with a new feature, it is best to add related tests.
- Please follow Contributor Covenant Code of Conduct.
@wwbmmm @yanglimingcn Please take a look.
@wwbmmm @yanglimingcn Friendly ping!
void* test(void*) {
while (!brpc::IsAskedToQuit()) {
sleep(2);
bthread_yield();
}
}
for (int i = 0; i < 3; ++i) {
bthread_t tid;
bthread_start_background(&tid, NULL, test, NULL);
}
Start 3 bthreads and loop sleep for 2s. The value of bthread_worker_usage is correct, and the extra 1 comes from the epoll bthread.
LGTM