MCPcopy Create free account
hub / github.com/apache/brpc / print_rq_sizes

Method print_rq_sizes

src/bthread/task_control.cpp:594–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594void TaskControl::print_rq_sizes(std::ostream& os) {
595 size_t ngroup = 0;
596 std::for_each(_tagged_ngroup.begin(), _tagged_ngroup.end(), [&](butil::atomic<size_t>& index) {
597 ngroup += index.load(butil::memory_order_relaxed);
598 });
599 DEFINE_SMALL_ARRAY(int, nums, ngroup, 128);
600 {
601 BAIDU_SCOPED_LOCK(_modify_group_mutex);
602 // ngroup > _ngroup: nums[_ngroup ... ngroup-1] = 0
603 // ngroup < _ngroup: just ignore _groups[_ngroup ... ngroup-1]
604 int i = 0;
605 for_each_task_group([&](TaskGroup* g) {
606 nums[i] = (g ? g->_rq.volatile_size() : 0);
607 ++i;
608 });
609 }
610 for (size_t i = 0; i < ngroup; ++i) {
611 os << nums[i] << ' ';
612 }
613}
614
615double TaskControl::get_cumulated_worker_time() {
616 int64_t cputime_ns = 0;
617 BAIDU_SCOPED_LOCK(_modify_group_mutex);
618 for_each_task_group([&](TaskGroup* g) {
619 cputime_ns += g->cumulated_cputime_ns();
620 });
621 return cputime_ns / 1000000000.0;
622}
623
624double TaskControl::get_cumulated_worker_time(bthread_tag_t tag) {
625 int64_t cputime_ns = 0;
626 BAIDU_SCOPED_LOCK(_modify_group_mutex);
627 const size_t ngroup = tag_ngroup(tag).load(butil::memory_order_relaxed);
628 auto& groups = tag_group(tag);
629 for (size_t i = 0; i < ngroup; ++i) {
630 cputime_ns += groups[i]->cumulated_cputime_ns();
631 }
632 return cputime_ns / 1000000000.0;
633}
634
635int64_t TaskControl::get_cumulated_switch_count() {
636 int64_t c = 0;
637 BAIDU_SCOPED_LOCK(_modify_group_mutex);
638 for_each_task_group([&](TaskGroup* g) {
639 if (g) {
640 c += g->_nswitch;
641 }
642 });
643 return c;
644}
645
646int64_t TaskControl::get_cumulated_signal_count() {
647 int64_t c = 0;
648 BAIDU_SCOPED_LOCK(_modify_group_mutex);
649 for_each_task_group([&](TaskGroup* g) {
650 if (g) {
651 c += g->_nsignaled + g->_remote_nsignaled;

Callers 2

TEST_FFunction · 0.80
print_rq_sizes_in_the_tcFunction · 0.80

Calls 12

volatile_sizeMethod · 0.80
get_versionFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
loadMethod · 0.45
cumulated_cputime_nsMethod · 0.45
lockMethod · 0.45
storeMethod · 0.45
unlockMethod · 0.45
exposeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by 1

TEST_FFunction · 0.64