title: Bench mark a Python parallel, why does Ubuntu perform slower than Windows?
body: <p>I am running a set of <a href="https://stackoverflow.com/q/57820724/10449636">parallel</a> computing on Intel(R) Xeon(R)          L5640 (6 cores 12 siblings) with following 2 platforms</p>
  
  <ul>
  <li><p>Ubuntu 18.04, Python 3.7.3, numpy 1.16.4, sklearn 0.21.2.</p></li>
  <li><p>Windows 7 ultimate, Python 3.7.3, numpy 1.16.4, sklearn 0.21.2.</p></li>
  </ul>
  
  <p>no any other jobs/tasks occupy the cpu cores. </p>
  
  <p>I bench marked this program and got some stats.</p>
  
  <pre><code>from sklearn.neighbors import KNeighborsClassifier
  from sklearn.metrics import classification_report
  from sklearn.model_selection import train_test_split
  from sklearn.datasets import fetch_openml
  import time
  X, y = fetch_openml('mnist_784', version=1, return_X_y=True)
  (trainData, testData, trainLabels, testLabels) = train_test_split(X,
  y, test_size=0.1)
  
  start = time.time()
  model = KNeighborsClassifier(n_jobs=4)
  model.fit(trainData, trainLabels)
  predictions = model.predict(testData)
  print('n_jobs=4 took {}s'.format(time.time() - start))
  </code></pre>
  
  <p>it took about 470s both on Ubuntu and Windows, which is reasonable.</p>
  
  <p>and then I ran this</p>
  
  <pre><code>start = time.time()
  model = KNeighborsClassifier(n_jobs=6)
  model.fit(trainData, trainLabels)
  predictions = model.predict(testData)
  print('n_jobs=6 took {}s'.format(time.time() - start))
  </code></pre>
  
  <p>it took about 493s on Ubuntu and 350s on Windows, where the part on windows is reasonable but the part on Ubuntu is NOT.</p>
  
  <p>n_jobs=6 take less time than n_jobs=4 on Windows, which is reasonable, since the code utilizes more cpu cores.</p>
  
  <p>n_jobs=6 take more time than n_jobs=4 on Ubuntu, which is NOT reasonable.</p>
  
  <p>this indicates that the joblib parallel with default backend performs different logic between Ubuntu and Windows.</p>
  
  <p>and then I searched in the <a href="https://joblib.readthedocs.io/en/latest/parallel.html" rel="nofollow noreferrer">doc</a>. but the doc involves "windows" is about 'multiprocessing' backend, which does not apply here, since mine is '0.13.2'.</p>
  
  <p>So, why does Ubuntu perform slower than Windows?</p>