tustvold commented on issue #2079:
URL: 
https://github.com/apache/arrow-datafusion/issues/2079#issuecomment-1083313672


   > Or do I miss something crucial that one SendableRecordBatchStream can be 
parallel processed by multiple tokio tasks
   
   Depends, the SendableRecordBatchStream itself can only be processed by a 
single tokio task correct, however, there is nothing to prevent that stream 
from actually being an mpsc channel with the actual work performed in other 
tasks in parallel. In fact this is exactly what CoalescePartitionsExec does, 
and the physical optimizer will add combinations of RepartitionExec and 
CoalescePartitionsExec to plans based on the target_partitions setting.
   
   Whilst target_partitions is typically set to the CPU thread count, 
RepartitionExec will typically appear multiple times in a given plan, and so 
this will result in more tasks than CPU cores. If there are other queries 
running concurrently, or the target_partitions is set higher, this will be even 
more pronounced. If you now squint, this is a first-order approximation of 
morsel-driven. It's far from perfect, the tokio scheduler is not in anyway 
NUMA-aware and in fact it optimises for load-distribution at the expense of 
thread-locality, but it is not hugely dissimilar.
   
   At least that's my hand-wavy argument :laughing: I happen to think rayon is 
closer in spirit, but I'm not sure how much of a difference that will make in 
practice.


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