Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/bthread/task_control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,20 @@ int TaskControl::init(int concurrency) {
for (int i = 0; i < FLAGS_task_group_ntags; ++i) {
_tagged_ngroup[i].store(0, std::memory_order_relaxed);
auto tag_str = std::to_string(i);
_tagged_nworkers.push_back(new bvar::Adder<int64_t>("bthread_worker_count", tag_str));
_tagged_cumulated_worker_time.push_back(new bvar::PassiveStatus<double>(
get_cumulated_worker_time_from_this_with_tag, new CumulatedWithTagArgs{this, i}));
_tagged_worker_usage_second.push_back(new bvar::PerSecond<bvar::PassiveStatus<double>>(
"bthread_worker_usage", tag_str, _tagged_cumulated_worker_time[i], 1));
_tagged_nbthreads.push_back(new bvar::Adder<int64_t>("bthread_count", tag_str));
_tagged_nworkers.emplace_back(
std::make_unique<bvar::Adder<int64_t>>("bthread_worker_count", tag_str));
_tagged_cumulated_worker_time_args.emplace_back(
std::make_unique<CumulatedWithTagArgs>(this, i));
_tagged_cumulated_worker_time.emplace_back(
std::make_unique<bvar::PassiveStatus<double>>(
get_cumulated_worker_time_from_this_with_tag,
_tagged_cumulated_worker_time_args.back().get()));
_tagged_worker_usage_second.emplace_back(
std::make_unique<bvar::PerSecond<bvar::PassiveStatus<double>>>(
"bthread_worker_usage", tag_str,
_tagged_cumulated_worker_time.back().get(), 1));
_tagged_nbthreads.emplace_back(
std::make_unique<bvar::Adder<int64_t>>("bthread_count", tag_str));
}

if (init_ed_priority_queues() != 0) {
Expand Down
13 changes: 9 additions & 4 deletions src/bthread/task_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DECLARE_int32(task_group_ntags);
namespace bthread {

class TaskGroup;
struct CumulatedWithTagArgs;

// Control all task groups
class TaskControl {
Expand Down Expand Up @@ -171,10 +172,14 @@ friend bthread_t init_for_pthread_stack_trace();
bvar::PassiveStatus<std::string> _status;
bvar::Adder<int64_t> _nbthreads;

std::vector<bvar::Adder<int64_t>*> _tagged_nworkers;
std::vector<bvar::PassiveStatus<double>*> _tagged_cumulated_worker_time;
std::vector<bvar::PerSecond<bvar::PassiveStatus<double>>*> _tagged_worker_usage_second;
std::vector<bvar::Adder<int64_t>*> _tagged_nbthreads;
std::vector<std::unique_ptr<bvar::Adder<int64_t>>> _tagged_nworkers;
std::vector<std::unique_ptr<CumulatedWithTagArgs>>
_tagged_cumulated_worker_time_args;
std::vector<std::unique_ptr<bvar::PassiveStatus<double>>>
_tagged_cumulated_worker_time;
std::vector<std::unique_ptr<bvar::PerSecond<bvar::PassiveStatus<double>>>>
_tagged_worker_usage_second;
std::vector<std::unique_ptr<bvar::Adder<int64_t>>> _tagged_nbthreads;

bool _enable_priority_queue;
int _ed_priority_queue_num_of_each_tag;
Expand Down
Loading