You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Antoine Pitrou (Jira)" <ji...@apache.org> on 2021/01/26 18:34:00 UTC
[jira] [Resolved] (ARROW-10038) [C++] SetCpuThreadPoolCapacity(1)
spins up nCPUs threads
[ https://issues.apache.org/jira/browse/ARROW-10038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Antoine Pitrou resolved ARROW-10038.
------------------------------------
Fix Version/s: 4.0.0
Resolution: Fixed
Issue resolved by pull request 8240
[https://github.com/apache/arrow/pull/8240]
> [C++] SetCpuThreadPoolCapacity(1) spins up nCPUs threads
> --------------------------------------------------------
>
> Key: ARROW-10038
> URL: https://issues.apache.org/jira/browse/ARROW-10038
> Project: Apache Arrow
> Issue Type: Bug
> Components: C++
> Affects Versions: 1.0.1
> Reporter: Adam Hooper
> Assignee: Antoine Pitrou
> Priority: Minor
> Labels: pull-request-available
> Fix For: 4.0.0
>
> Time Spent: 3h 10m
> Remaining Estimate: 0h
>
> When I call {{arrow::SetCpuThreadPoolCapacity(1);}}, Arrow does this:
> 1. Spins up a singleton {{ThreadPool}} with _the default thread count_;
> 2. Sets the number of threads on that {{ThreadPool}} to 1 -- killing the extra threads.
> On my Intel system, I'm forced to spin up four threads to set the CPU thread-pool capacity to 1. This goes against the spirit of the API method -- or at least, my understanding of it (and my experience with other thread pools).
> My workaround, for calling code: instead of calling {{arrow::SetCpuThreadPoolCapacity(1)}}, call {{setenv("OMP_NUM_THREADS", "1", 1)}}.
> Brainstorming, here are some ideas for Arrow's global thread pool that would stop launching {{>limit}} threads to set the limit:
> * {{cpu_thread_pool_capacity}} could be a global variable, not an attribute on the global {{ThreadPool}}. API users would be expected to set the thread-pool capacity _before_ creating the thread pool. (They're probably doing this anyway.)
> * {{SetCpuThreadPoolCapacity()}} could call {{setenv("OMP_NUM_THREADS", ...)}}
> * {{ThreadPool}} could create threads on-demand instead of in the ctor. An unused {{ThreadPool}} would launch zero threads -- resolving ARROW-10033 as a side-effect
--
This message was sent by Atlassian Jira
(v8.3.4#803005)