Github user holdenk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18281#discussion_r128632738
  
    --- Diff: python/pyspark/ml/classification.py ---
    @@ -1564,8 +1568,9 @@ def trainSingleClass(index):
                                 (classifier.predictionCol, predictionCol)])
                 return classifier.fit(trainingDataset, paramMap)
     
    -        # TODO: Parallel training for all classes.
    -        models = [trainSingleClass(i) for i in range(numClasses)]
    +        pool = ThreadPool(processes=min(self.getParallelism(), numClasses))
    +
    +        models = pool.map(trainSingleClass, range(numClasses))
    --- End diff --
    
    So if the training of the models takes different times and there is a 
relatively large number of models we might end up blocking a worker here since 
the map effectively splits in advance. What do you think of providing a 
chunksize hint or using `imap` or `imap_unordered` instead? Since the overhead 
of sending the element to the worker should be relatively small compared to the 
time it takes to train the model?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to