Skip to content

Commit

Permalink
Check CPU cores in CPUAffinityManagerTest (#7473) (#7476)
Browse files Browse the repository at this point in the history
close #7472
  • Loading branch information
ti-chi-bot authored May 16, 2023
1 parent 1234ed4 commit 80d2e18
Showing 1 changed file with 11 additions and 0 deletions.
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

0 comments on commit 80d2e18

Please sign in to comment.