yiguolei commented on code in PR #38238:
URL: https://github.com/apache/doris/pull/38238#discussion_r1689544440
##########
be/src/runtime/workload_group/workload_group.cpp:
##########
@@ -541,6 +562,40 @@ std::string WorkloadGroup::thread_debug_info() {
return str;
}
+void WorkloadGroup::upsert_scan_io_throttle(WorkloadGroupInfo* tg_info) {
+ if (!ExecEnv::ready()) {
+ return;
+ }
+ std::vector<DataDirInfo>& data_dir_list = BaseStorageEngine::data_dir_list;
+
+ std::lock_guard<std::shared_mutex> wl {_mutex};
+ if (_scan_io_throttle_map.size() == 0) {
+ for (const auto& data_dir : data_dir_list) {
+ _scan_io_throttle_map[data_dir.path] =
std::make_shared<IOThrottle>();
+ }
+ }
+ for (const auto& [key, io_throttle] : _scan_io_throttle_map) {
+ io_throttle->set_io_bytes_per_second(tg_info->read_bytes_per_second);
+ }
+
+ if (!_remote_scan_io_throttle) {
+ _remote_scan_io_throttle = std::make_shared<IOThrottle>();
+ }
+
_remote_scan_io_throttle->set_io_bytes_per_second(tg_info->remote_read_bytes_per_second);
+}
+
+std::shared_ptr<IOThrottle> WorkloadGroup::get_scan_io_throttle(std::string
disk_dir) {
+ std::shared_lock<std::shared_mutex> rl {_mutex};
Review Comment:
这里用lock 可能有风险,就是这个调用太底层了,调用的人可能很多。
可以把这个throttle的map
包装成一个对象,使用https://en.cppreference.com/w/cpp/memory/shared_ptr/atomic2
来管理这个map 对象,这样每次进来,只要拿到这个map 然后操作就好了
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]