<p dir="auto">I ran my <a href="https://github.com/ranjanan/MT-Workloads/blob/master/Logistic%20Regression/logreg.jl">Logistic Regression benchmark</a> for threads. Not sure if this is related to earlier issues or not, but I thought I'd post an issue anyway.<br>
Usually the output would be (on a version of master sometime in January)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Warm up run : 25 iterations!
Time taken by serial implementation = 1.508228316
Time taken by parallel implementation = 0.429550363
Speedup over 4 threads : 3.5111792374390336"><pre class="notranslate"><code class="notranslate">Warm up run : 25 iterations!
Time taken by serial implementation = 1.508228316
Time taken by parallel implementation = 0.429550363
Speedup over 4 threads : 3.5111792374390336
</code></pre></div>
<p dir="auto">Now, with the current threaded build of master, it's this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Warm up run : 25 iterations!
Time taken by serial implementation = 1.831504341
Time taken by parallel implementation = 42.974081761
Speedup over 4 threads : 0.04261881268774738"><pre class="notranslate"><code class="notranslate">Warm up run : 25 iterations!
Time taken by serial implementation = 1.831504341
Time taken by parallel implementation = 42.974081761
Speedup over 4 threads : 0.04261881268774738
</code></pre></div>
<p dir="auto">Consider the following code:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="using Base.Threads
println(&quot;Number of threads = $(nthreads())&quot;)
x = rand(10^6)
y = zeros(10^6)
println(&quot;Warmup!&quot;)
for i = 1:10^6
    y[i] = sin(x[i])^2 + cos(x[i])^2
end
t1 = @elapsed for i = 1:10^6
    y[i] = sin(x[i])^2 + cos(x[i])^2
end
@assert sum(y) == 10^6
t2 = @elapsed @threads for i = 1:10^6
    y[i] = sin(x[i])^2 + cos(x[i])^2
end
@assert sum(y) == 10^6
println(&quot;Serial time = $t1&quot;)
println(&quot;Parallel time = $t2&quot;)"><pre class="notranslate"><span class="pl-k">using</span> Base<span class="pl-k">.</span>Threads
<span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>Number of threads = <span class="pl-v">$(<span class="pl-c1">nthreads</span>())</span><span class="pl-pds">"</span></span>)
x <span class="pl-k">=</span> <span class="pl-c1">rand</span>(<span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>)
y <span class="pl-k">=</span> <span class="pl-c1">zeros</span>(<span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>)
<span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>Warmup!<span class="pl-pds">"</span></span>)
<span class="pl-k">for</span> i <span class="pl-k">=</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>
    y[i] <span class="pl-k">=</span> <span class="pl-c1">sin</span>(x[i])<span class="pl-k">^</span><span class="pl-c1">2</span> <span class="pl-k">+</span> <span class="pl-c1">cos</span>(x[i])<span class="pl-k">^</span><span class="pl-c1">2</span>
<span class="pl-k">end</span>
t1 <span class="pl-k">=</span> <span class="pl-c1">@elapsed</span> <span class="pl-k">for</span> i <span class="pl-k">=</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>
    y[i] <span class="pl-k">=</span> <span class="pl-c1">sin</span>(x[i])<span class="pl-k">^</span><span class="pl-c1">2</span> <span class="pl-k">+</span> <span class="pl-c1">cos</span>(x[i])<span class="pl-k">^</span><span class="pl-c1">2</span>
<span class="pl-k">end</span>
<span class="pl-c1">@assert</span> <span class="pl-c1">sum</span>(y) <span class="pl-k">==</span> <span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>
t2 <span class="pl-k">=</span> <span class="pl-c1">@elapsed</span> <span class="pl-c1">@threads</span> <span class="pl-k">for</span> i <span class="pl-k">=</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>
    y[i] <span class="pl-k">=</span> <span class="pl-c1">sin</span>(x[i])<span class="pl-k">^</span><span class="pl-c1">2</span> <span class="pl-k">+</span> <span class="pl-c1">cos</span>(x[i])<span class="pl-k">^</span><span class="pl-c1">2</span>
<span class="pl-k">end</span>
<span class="pl-c1">@assert</span> <span class="pl-c1">sum</span>(y) <span class="pl-k">==</span> <span class="pl-c1">10</span><span class="pl-k">^</span><span class="pl-c1">6</span>
<span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>Serial time = <span class="pl-v">$t1</span><span class="pl-pds">"</span></span>)
<span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span>Parallel time = <span class="pl-v">$t2</span><span class="pl-pds">"</span></span>)</pre></div>
<p dir="auto">The output recorded on OSX is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Number of threads = 4
Warmup!
Serial time = 0.239838418
Parallel time = 0.282324893"><pre class="notranslate"><code class="notranslate">Number of threads = 4
Warmup!
Serial time = 0.239838418
Parallel time = 0.282324893
</code></pre></div>
<p dir="auto">The output recorded on Linux is:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Number of threads = 4
Warmup!
Serial time = 0.227327406
Parallel time = 0.542067206"><pre class="notranslate"><code class="notranslate">Number of threads = 4
Warmup!
Serial time = 0.227327406
Parallel time = 0.542067206
</code></pre></div>