Can Dask provide a speedup for 1D arrays?
<p>When working on 2D data, I see a slight speed-up on 2D arrays, but even on large 1D arrays that advantage disappears.</p>

<p>E.g., in 2D:</p>

<pre><code>In [48]: x = np.random.random((3000, 2000))

In [49]: X = da.from_array(x, chunks=(500,500))

In [50]: %timeit (np.cumsum(x - x**2, axis=0)) 
10 loops, best of 3: 131 ms per loop

In [51]: %timeit (da.cumsum(X - X**2, axis=0)).compute()
10 loops, best of 3: 89.3 ms per loop
</code></pre>

<p>But in 1D:</p>

<pre><code>In [52]: x = np.random.random(10e5)

In [53]: X = da.from_array(x, chunks=(2000,))

In [54]: %timeit (np.cumsum(x - x**2, axis=0)) 
100 loops, best of 3: 8.28 ms per loop

In [55]: %timeit (da.cumsum(X - X**2, axis=0)).compute()
1 loop, best of 3: 304 ms per loop
</code></pre>

<p>Can Dask provide a speedup for 1D arrays and, if so, what would an ideal chunk size be?</p>

<p>Your FLOP/Byte ratio is still too low.  The CPU isn't the bottleneck, your memory hierarchy is.  </p>

<p>Additionally, chunksizes of (2000,) are just too small for Dask.array to be meaningful.  Recall that dask introduces an overhead of a few hundred microseconds per task, so each task you do should be significantly longer than this.  This explains the 300ms duration you're seeing.</p>

<pre><code>In [11]: 10e5 / 2000  # number of tasks
Out[11]: 500.0
</code></pre>

<p>But even if you do go for larger chunksizes you don't get any speedup on this computation:</p>

<pre><code>In [15]: x = np.random.random(1e8)
In [16]: X = da.from_array(x, chunks=1e6)

In [17]: %timeit np.cumsum(x - x**2, axis=0)
1 loop, best of 3: 632 ms per loop

In [18]: %timeit da.cumsum(X - X**2, axis=0).compute()
1 loop, best of 3: 759 ms per loop
</code></pre>

<p>However if you do something that requires more computation per byte then you enter the regime where parallel processing can actually help.  For example arcsinh is actually quite costly to compute:</p>

<pre><code>In [20]: %timeit np.arcsinh(x).sum()
1 loop, best of 3: 3.32 s per loop

In [21]: %timeit da.arcsinh(X).sum().compute()
1 loop, best of 3: 724 ms per loop
</code></pre>

python dask