cyb70289 commented on code in PR #46034:
URL: https://github.com/apache/arrow/pull/46034#discussion_r2032287921


##########
cpp/src/arrow/util/thread_pool_test.cc:
##########
@@ -1039,35 +1040,63 @@ TEST(TestGlobalThreadPool, Capacity) {
   // Exercise default capacity heuristic
   ASSERT_OK(DelEnvVar("OMP_NUM_THREADS"));
   ASSERT_OK(DelEnvVar("OMP_THREAD_LIMIT"));
+
+#ifdef __linux__
+  int expected_capacity = arrow::internal::GetAffinityCpuCount();
+#else
   int hw_capacity = std::thread::hardware_concurrency();
-  ASSERT_EQ(ThreadPool::DefaultCapacity(), hw_capacity);
+  int expected_capacity = hw_capacity;
+#endif
+
+  ASSERT_EQ(ThreadPool::DefaultCapacity(), expected_capacity);
+
   ASSERT_OK(SetEnvVar("OMP_NUM_THREADS", "13"));
   ASSERT_EQ(ThreadPool::DefaultCapacity(), 13);
+
   ASSERT_OK(SetEnvVar("OMP_NUM_THREADS", "7,5,13"));
   ASSERT_EQ(ThreadPool::DefaultCapacity(), 7);
   ASSERT_OK(DelEnvVar("OMP_NUM_THREADS"));
 
   ASSERT_OK(SetEnvVar("OMP_THREAD_LIMIT", "1"));
   ASSERT_EQ(ThreadPool::DefaultCapacity(), 1);
+
   ASSERT_OK(SetEnvVar("OMP_THREAD_LIMIT", "999"));
-  if (hw_capacity <= 999) {
-    ASSERT_EQ(ThreadPool::DefaultCapacity(), hw_capacity);
-  }
+#ifdef __linux__
+  ASSERT_EQ(ThreadPool::DefaultCapacity(), std::min(999, 
arrow::internal::GetAffinityCpuCount()));
+#else
+  ASSERT_EQ(ThreadPool::DefaultCapacity(), std::min(999, hw_capacity));
+#endif

Review Comment:
   Can we simplify it? Leave only line 1065, and remove `hw_capacity`?
   



-- 
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]

Reply via email to