Skip to content

Commit

Permalink
Re-enable CacheLocality.LinuxActual test under remote execution
Browse files Browse the repository at this point in the history
Reviewed By: r1mikey

Differential Revision: D61265741

fbshipit-source-id: dd8456bd450fa46fd967fcbb9195e510355ca313
  • Loading branch information
ot authored and facebook-github-bot committed Aug 14, 2024
1 parent d52419b commit 475b862
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions folly/concurrency/test/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cpp_unittest(
"//folly/concurrency:cache_locality",
"//folly/portability:gtest",
"//folly/portability:sys_resource",
"//folly/portability:unistd",
"//folly/test:test_utils",
],
external_deps = [
Expand Down
12 changes: 7 additions & 5 deletions folly/concurrency/test/CacheLocalityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include <folly/concurrency/CacheLocality.h>

#include <cstdlib>
#include <memory>
#include <thread>
#include <unordered_map>
Expand All @@ -25,6 +24,7 @@
#include <fmt/ranges.h>
#include <folly/portability/GTest.h>
#include <folly/portability/SysResource.h>
#include <folly/portability/Unistd.h>
#include <folly/test/TestUtils.h>

#include <glog/logging.h>
Expand Down Expand Up @@ -981,14 +981,16 @@ TEST(CacheLocality, LinuxActual) {
return;
}

auto in_re = ::getenv("RE_PLATFORM");
SKIP_IF(in_re != nullptr);
// CacheLocality reports the topology for all cpus, even those that are not
// available in the current environment (for example a container with pinned
// CPUs), so we can't use _SC_NPROCESSORS_ONLN or std::hardware_concurrency().
auto expectedNumCpus = sysconf(_SC_NPROCESSORS_CONF);

auto parsed1 = CacheLocality::readFromProcCpuinfo();
EXPECT_EQ(parsed1.numCpus, std::thread::hardware_concurrency());
EXPECT_EQ(parsed1.numCpus, expectedNumCpus);

auto parsed2 = CacheLocality::readFromSysfs();
EXPECT_EQ(parsed2.numCpus, std::thread::hardware_concurrency());
EXPECT_EQ(parsed2.numCpus, expectedNumCpus);

LOG(INFO) << fmt::format(
"[cpuinfo] numCachesByLevel={}", parsed1.numCachesByLevel);
Expand Down

0 comments on commit 475b862

Please sign in to comment.