felipecrv commented on issue #40301: URL: https://github.com/apache/arrow/issues/40301#issuecomment-1973186955
I’ve taken a look at the code. `OptionalParallelFor` is used when `PandasOptions::use_threads` is set. Internally, it uses the default CPU thread pool which can allocate CPU-count threads at a time. That’s why it allocates CPU-count threads as @anjakefala described. My first solution/idea: add another option to `PandasOptions` — `int threads`. Then if that’s different than 0, create a different `ThreadPool` with that as capacity when calling the parallel-for. Easy, but it’s an extra option that users have to remember to set. ### Alternative Add more parameters to parallel-for(columns) that modify the loop that submits tasks to the thread-pool: Start with a low minimum number of submitted tasks (eg 2. each column is a task). After that, tasks are added with a small delay (microseconds) as to give the chance of the initially submitted tasks to finish (because cols are small) and make these initially used threads to be re-used. This might require internal `ThreadPool` changes to avoid waits that wouldn’t lead to a global reduction in time taken to convert all columns. -- 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]
