Skip to content

Commit

Permalink
cherry-pick #7693 (#7712)
Browse files Browse the repository at this point in the history
  • Loading branch information
windtalker authored Jun 28, 2023
1 parent 4e0e674 commit 1433068
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions dbms/src/Common/tests/gtest_cpu_affinity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@

#include <Common/CPUAffinityManager.h>
#include <Common/Config/TOMLConfiguration.h>
#include <Common/Logger.h>
#include <Poco/Util/LayeredConfiguration.h>
#include <boost_wrapper/string.h>
#include <common/logger_useful.h>
#include <gtest/gtest.h>
#include <unistd.h>

Expand Down Expand Up @@ -82,6 +84,15 @@ TEST(CPUAffinityManagerTest, CPUAffinityManager)
int ret = sched_getaffinity(0, sizeof(cpu_set), &cpu_set);
ASSERT_EQ(ret, 0) << strerror(errno);

auto n_cpu = std::thread::hardware_concurrency();
auto cpu_cores = cpu_affinity.cpuSetToVec(cpu_set);
if (n_cpu != cpu_cores.size())
{
LOG_INFO(Logger::get(), "n_cpu = {}, cpu_cores = {}, CPU number and CPU cores not match, don't not check CPUAffinityManager", n_cpu, cpu_cores);
return;
}
LOG_DEBUG(Logger::get(), "n_cpu = {}, cpu_cores = {}", n_cpu, cpu_cores);

cpu_affinity.bindSelfQueryThread();
cpu_set_t cpu_set0;
ret = sched_getaffinity(0, sizeof(cpu_set0), &cpu_set0);
Expand Down
2 changes: 1 addition & 1 deletion dbms/src/Flash/Mpp/MinTSOScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool MinTSOScheduler::scheduleImp(const UInt64 tso, const MPPQueryTaskSetPtr & q
{
auto needed_threads = schedule_entry.getNeededThreads();
auto check_for_new_min_tso = tso <= min_tso && estimated_thread_usage + needed_threads <= thread_hard_limit;
auto check_for_not_min_tso = (active_set.size() < active_set_soft_limit || tso <= *active_set.rbegin()) && (estimated_thread_usage + needed_threads <= thread_soft_limit);
auto check_for_not_min_tso = (active_set.size() < active_set_soft_limit || active_set.find(tso) != active_set.end()) && (estimated_thread_usage + needed_threads <= thread_soft_limit);
if (check_for_new_min_tso || check_for_not_min_tso)
{
updateMinTSO(tso, false, isWaiting ? "from the waiting set" : "when directly schedule it");
Expand Down

0 comments on commit 1433068

Please sign in to comment.