forked from deepseek-ai/3FS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecutorStatsReporter.cc
More file actions
42 lines (33 loc) · 1.92 KB
/
Copy pathExecutorStatsReporter.cc
File metadata and controls
42 lines (33 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "common/utils/ExecutorStatsReporter.h"
#include <folly/executors/IOThreadPoolExecutor.h>
#include "common/utils/CPUExecutorGroup.h"
namespace hf3fs {
namespace {
monitor::CountRecorder threadCountRecorder{"thread_pool_group.thread_count"};
monitor::CountRecorder idleThreadCountRecorder{"thread_pool_group.idle_thread_count"};
monitor::CountRecorder activeThreadCountRecorder{"thread_pool_group.active_thread_count"};
monitor::CountRecorder pendingTaskCountRecorder{"thread_pool_group.pending_task_count"};
monitor::CountRecorder totalTaskCountRecorder{"thread_pool_group.total_task_count"};
} // namespace
template <class T>
ExecutorStatsReporter<T>::ExecutorStatsReporter(const T &executor)
: executor_(executor),
threadCountRecorder_(threadCountRecorder.getRecorderWithTag(monitor::threadTagSet(executor.getName()))),
idleThreadCountRecorder_(idleThreadCountRecorder.getRecorderWithTag(monitor::threadTagSet(executor.getName()))),
activeThreadCountRecorder_(
activeThreadCountRecorder.getRecorderWithTag(monitor::threadTagSet(executor.getName()))),
pendingTaskCountRecorder_(pendingTaskCountRecorder.getRecorderWithTag(monitor::threadTagSet(executor.getName()))),
totalTaskCountRecorder_(totalTaskCountRecorder.getRecorderWithTag(monitor::threadTagSet(executor.getName()))) {}
template <class T>
void ExecutorStatsReporter<T>::report() {
auto stats = executor_.getPoolStats();
threadCountRecorder_->addSample(stats.threadCount);
idleThreadCountRecorder_->addSample(stats.idleThreadCount);
activeThreadCountRecorder_->addSample(stats.activeThreadCount);
pendingTaskCountRecorder_->addSample(stats.pendingTaskCount);
totalTaskCountRecorder_->addSample(stats.totalTaskCount);
}
template class ExecutorStatsReporter<CPUExecutorGroup>;
template class ExecutorStatsReporter<folly::CPUThreadPoolExecutor>;
template class ExecutorStatsReporter<folly::IOThreadPoolExecutor>;
} // namespace hf3fs