Skip to content
Merged
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
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ option(CGRAPH_BUILD_PERFORMANCE_TESTS "Enable build performance tests" OFF)
# 如果开启此宏定义,则CGraph执行过程中,不会在控制台打印任何信息
# add_definitions(-D_CGRAPH_SILENCE_)

# 如果开启此宏定义,则在结束过程中,会展示thread pool中的调度信息
# 本信息主要用于作者性能调优使用,不保证所有数据完全正确
# 不建议作为验证自行逻辑的唯一标准,不建议使用者打开
# add_definitions(-D_CGRAPH_SHOW_THREAD_METRICS_)

# 此宏可以在纯并发的微小任务下,用于提升整体性能。主要用于在性能测试的情况下使用,一般情况不推荐打开
# add_definitions(-D_CGRAPH_PARALLEL_MICRO_BATCH_ENABLE_)

Expand Down
141 changes: 0 additions & 141 deletions src/UtilsCtrl/ThreadPool/Metrics/UMetrics.h

This file was deleted.

4 changes: 0 additions & 4 deletions src/UtilsCtrl/ThreadPool/Thread/UThreadBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "../UThreadObject.h"
#include "../Queue/UQueueInclude.h"
#include "../Task/UTaskInclude.h"
#include "../Metrics/UMetrics.h"


CGRAPH_NAMESPACE_BEGIN
Expand Down Expand Up @@ -57,7 +56,6 @@ class UThreadBase : public UThreadObject {
// 如果辅助线程没有获取到的话,还需要再尝试从长时间任务队列中,获取一次
result = pool_priority_task_queue_->tryPop(task);
}
metrics_.calcPool(result, 1);
return result;
}

Expand All @@ -73,7 +71,6 @@ class UThreadBase : public UThreadObject {
result = pool_priority_task_queue_->tryPop(tasks, 1); // 从优先队列里,最多pop出来一个
}

metrics_.calcPool(result, tasks.size());
return result;
}

Expand Down Expand Up @@ -248,7 +245,6 @@ class UThreadBase : public UThreadObject {
UAtomicQueue<UTask>* pool_task_queue_; // 用于存放线程池中的普通任务
UAtomicPriorityQueue<UTask>* pool_priority_task_queue_; // 用于存放线程池中的包含优先级任务的队列,仅辅助线程可以执行
UThreadPoolConfigPtr config_ = nullptr; // 配置参数信息
UMetrics metrics_; // 线程中的指标信息

std::thread thread_; // 线程类
std::mutex mutex_;
Expand Down
20 changes: 0 additions & 20 deletions src/UtilsCtrl/ThreadPool/Thread/UThreadPrimary.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class UThreadPrimary : public UThreadBase {
CGRAPH_ASSERT_NOT_NULL(config_)

is_init_ = true;
metrics_.reset();
buildStealTargets();
thread_ = std::thread(&UThreadPrimary::run, this);
setSchedParam();
Expand Down Expand Up @@ -116,12 +115,10 @@ class UThreadPrimary : public UThreadBase {
*/
CVoid fatWait() {
cur_empty_epoch_++;
metrics_.fleet_wait_times_++;
CGRAPH_YIELD();
if (cur_empty_epoch_ >= config_->primary_thread_busy_epoch_) {
CGRAPH_UNIQUE_LOCK lk(mutex_);
cv_.wait_for(lk, std::chrono::milliseconds(config_->primary_thread_empty_interval_));
metrics_.deep_wait_times_++;
cur_empty_epoch_ = 0;
}
}
Expand All @@ -135,11 +132,9 @@ class UThreadPrimary : public UThreadBase {
CVoid pushTask(UTask&& task) {
while (!(primary_queue_.tryPush(std::move(task))
|| secondary_queue_.tryPush(std::move(task)))) {
metrics_.local_push_yield_times_++;
CGRAPH_YIELD();
}
cur_empty_epoch_ = 0;
metrics_.local_push_real_num_++;
cv_.notify_one();
}

Expand All @@ -157,8 +152,6 @@ class UThreadPrimary : public UThreadBase {
cur_empty_epoch_ = 0;
cv_.notify_one();
}
metrics_.local_push_yield_times_++;
metrics_.local_push_real_num_++;
}


Expand All @@ -169,7 +162,6 @@ class UThreadPrimary : public UThreadBase {
*/
CBool popTask(UTaskRef task) {
auto result = primary_queue_.tryPop(task) || secondary_queue_.tryPop(task);
metrics_.calcLocal(result, 1);
return result;
}

Expand All @@ -186,7 +178,6 @@ class UThreadPrimary : public UThreadBase {
// 如果凑齐了,就不需要了。没凑齐的话,就继续
result |= (secondary_queue_.tryPop(tasks, leftSize));
}
metrics_.calcLocal(result, tasks.size());
return result;
}

Expand Down Expand Up @@ -224,7 +215,6 @@ class UThreadPrimary : public UThreadBase {
}
}

metrics_.calcSteal(result, 1);
return result;
}

Expand Down Expand Up @@ -260,7 +250,6 @@ class UThreadPrimary : public UThreadBase {
}
}

metrics_.calcSteal(result, tasks.size());
return result;
}

Expand All @@ -278,15 +267,6 @@ class UThreadPrimary : public UThreadBase {
steal_targets_.shrink_to_fit();
}


~UThreadPrimary() override {
/**
* 在开启展示宏的时候,会在主线程退出的时候,打印相关内容
* 默认情况下,不会开启
*/
metrics_.show("thread" + std::to_string(index_));
}

private:
CInt index_; // 线程index
CInt cur_empty_epoch_ = 0; // 当前空转的轮数信息
Expand Down
2 changes: 1 addition & 1 deletion src/UtilsCtrl/ThreadPool/UThreadPoolDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define CGRAPH_UTHREADPOOLDEFINE_H

#include <thread>
# include <mutex>
#include <mutex>
#if __cplusplus >= 201703L
#include <shared_mutex>
#endif
Expand Down
Loading