Repository navigation
Description
What happened:
Hello! After the 2.28.0 release the napari project is having some dask performance related issues, including timeout fails of some of tests that now take significantly longer. Changing the dask config did not recover the old behavior as I would have expected based on the docs.
A more detailed investigation can be found in the napari issue tracker here napari/napari#1656 but I will reproduce a minimal example below.
What you expected to happen:
I didn't expect such large slow downs with the new release.
Minimal Complete Verifiable Example:
import dask.array as da
import numpy as np
import time
data = da.random.random(
size=(100_000, 1000, 1000), chunks=(1, 1000, 1000)
)
idxs = [(0,), (50_000,), (99_999,)]
t0 = time.time()
reduced_data = np.min([np.min(data[idx]) for idx in idxs])
t1 = time.time()
print(t1 - t0)On 2.27.0 this takes about 0.13 seconds to run, on 2.28.0 this takes 4.3 seconds to run.
Anything else we need to know?:
Looking at the 2.28.0 release notes I saw #6665 and think this maybe related to that. I noticed the note on efficiency which suggested there may now be some additional overhead, but I didn't expect the slow down to be so large (note while the above is just a toy example, the slowdown is quite noticeable for real-world examples too).
I tried using
with dask.config.set({"array.slicing.split-large-chunks": False}):
data = da.random.random(
size=(100_000, 1000, 1000), chunks=(1, 1000, 1000)
)
idxs = [(0,), (50_000,), (99_999,)]
t0 = time.time()
reduced_data = np.min([np.min(data[idx]) for idx in idxs])
t1 = time.time()
print(t1 - t0)but I saw no difference between having the setting True or False in both this toy example, or in the real config inside napari if I added it to napari here. If I could get the config working as expected then I can just change the default value and we would be fine.
Environment:
- Dask version: 2.28.0
- Python version: 3.7
- Operating System: MacOS
- Install method (conda, pip, source): pip
Activity
TomAugspurger commentedon Oct 1, 2020
Sorry about the slowdown, and thanks for opening an issue.
My hope is that #6665 isn't to blame here. It should only apply at graph construction time, but it seems like the slowdown is in compute.
Right now my guess is that our new graph culling is to blame, but I'll bisect that now.
TomAugspurger commentedon Oct 1, 2020
Seems that f0b2ac2 (#6510) is the culprit.
@madsbk are you able to take a look? The full reproducer is
sofroniewn commentedon Oct 1, 2020
Thanks for looking in @TomAugspurger and identifying the commit!! It's much appreciated.
TomAugspurger commentedon Oct 1, 2020
@madsbk in case it helps narrow things down further, I notice that the slowdown is just in the optimization stage.
snakeviz suggests that we're spending a bunch of time (roughly 2/3rds) in
dask.core.keys_in_tasks.madsbk commentedon Oct 1, 2020
Yes, did a quick profile and in
masterwe are callingkeys_in_tasks()100012 times whereas2.27.0only calls in 14 times!madsbk commentedon Oct 1, 2020
I think I understand the issue. In
Layer.cull()we find the dependencies of all keys even thoughcull()might only traverse a few keys.We need to make HLG support a get-dependencies-of-a-single-key. I am happy to implement this but I am out-of-office must of tomorrow so it will have to wait till Monday :/
TomAugspurger commentedon Oct 1, 2020
Thanks for looking!
I believe that we're scheduled to have a release tomorrow. If we want to "fix" this regression for that release we could consider reverting #6510 for that release, and restoring it shortly after. It reverts cleanly, I haven't run the tests so I'm not sure what else that would necessitate reverting (maybe 7827330, and it would block work by others like Rick's ShuffleStage PR).
cc @jrbourbeau as well, if you have a preference for how to proceed.
madsbk commentedon Oct 1, 2020
Reverting is fine with me, it shouldn't effect 7827330 but yes it will block Rick's ShuffleStage and my follow up HLG work: #6689 and #6693.
jakirkham commentedon Oct 1, 2020
cc @rjzamora (for vis)
mrocklin commentedon Oct 2, 2020
After looking at this briefly I think that @madsbk fix will be fine, however I think it makes more sense logistically to revert in this case, release, let things settle over the weekend, and then go on a merging spree (there is a lot of interesting work in both dask/dask and dask/distributed).
@jrbourbeau are you still planning to handle the release today? If not I'm happy to do it.
sofroniewn commentedon Oct 2, 2020
I've just tested #6699 and confirmed it fixes the performance regression for me. I also asked a question about adding timing based tests that might actually be better for this thread rather than the PR. In napari we use the
pytest.mark.timeout(n)decorator in a few places to catch major performance regressions - see this test for example, which was very helpful for us identifying this performance regression - we saw it on our CI right away on the 2.28.0 release, and I'm wondering if some/ more rough tests like that might be helpful for dask too?