You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LocalCluster CPU usage climbs to 100% over time without submitting computations, connecting workers #4827
I noticed when I was working locally in a Jupyter Lab session on my laptop that computations would gradually slow down, down, down, until there was nothing to do but restart the notebook kernel (and therefore scheduler/workers). I started to pare down a minimal reproducing example, and got all the way down to launching a LocalCluster with zero workers. After five minutes, CPU use is hovering around 100%, and a few minutes later I start getting the message distributed.utils_perf - WARNING - full garbage collections took 19% CPU time recently repeated every ~1s. This is all without connecting a worker or trying to do any computation.
What happened: Requesting a LocalCluster results in a process that grows to use 100% of the CPU even when no workers are launched and no computations are requested.
What you expected to happen: CPU use should remain roughly static when not under load
Minimal Complete Verifiable Example:
fromdask.distributedimportClient, LocalClustercluster=LocalCluster(n_workers=0)
client=Client(cluster.scheduler.address)
# wait 5 minutes and check CPU use
Anything else we need to know?:
I also tried setting the loop implementation to uvloop in ~/.config/dask/dask.yaml and the issue persisted. Above screenshots are from running with the default config except for:
This appears to be an interaction between JupyterLab and Dask, since running the minimal reproducing code in a plain vanilla python session showed ~20% CPU consistently over time.
Yes, seems likely. It seems limited to the labextension display of the plots. Opening up the scheduler web UI directly doesn't accumulate CPU load the same way, in my testing. If you think it's better to continue over on the labextension issue tracker, I can move over there!
Here's a py-spy / speedscope.app profile trace of the scheduler that (if I'm reading it correctly) indicates most of the time is spent in Bokeh:
I think it's a problem with the bokeh server that it can't handle frequent requests without leaking memory, but there are also things we can probably do on the dask-labextension side to quiet down the number of requests. Let's continue discussion over in the linked issue, if you don't mind @joseph-long
Unrelated issue but following the development install instructions I ran in to this:
$ jupyter labextension develop . --overwrite
Traceback (most recent call last):
File "/Users/josephlong/devel/dask-labextension/setup.py", line 8, in <module>
from jupyter_packaging import (
ModuleNotFoundError: No module named 'jupyter_packaging'
An error occured.
FileNotFoundError: The Python package `.` is not a valid package, it is missing the `setup.py` file.
Had to pip install jupyter-packaging manually and then install worked.
Anyway, I've been running the PR version for a few minutes now and CPU use is constant! Hooray!
I've published a patch release of dask-labextension which avoids this behavior. It doesn't fix any underlying reference leaks on the scheduler, but should make it much less likely that users will run into them.
A small reproducer for this which is independent of using JupyterLab:
Activity
joseph-long commentedon May 18, 2021
This appears to be an interaction between JupyterLab and Dask, since running the minimal reproducing code in a plain vanilla
pythonsession showed ~20% CPU consistently over time.joseph-long commentedon May 18, 2021
Launching
dask-scheduleranddask-workerin a terminal and just connecting from JupyterLab does seem to result in asymptotically increasing CPU.jrbourbeau commentedon May 18, 2021
Thanks for reporting this issue @joseph-long! I tried this out locally and observed similar behavior.
cc @ian-r-rose due to the Jupyter connection
ian-r-rose commentedon May 18, 2021
Thanks for the ping! I wonder if this is at all related to dask/dask-labextension#185 .
joseph-long commentedon May 18, 2021
Yes, seems likely. It seems limited to the labextension display of the plots. Opening up the scheduler web UI directly doesn't accumulate CPU load the same way, in my testing. If you think it's better to continue over on the labextension issue tracker, I can move over there!
Here's a py-spy / speedscope.app profile trace of the scheduler that (if I'm reading it correctly) indicates most of the time is spent in Bokeh:
View in speedscope
ian-r-rose commentedon May 18, 2021
xref: dask/dask-labextension#185 (comment)
I think it's a problem with the bokeh server that it can't handle frequent requests without leaking memory, but there are also things we can probably do on the
dask-labextensionside to quiet down the number of requests. Let's continue discussion over in the linked issue, if you don't mind @joseph-longian-r-rose commentedon May 18, 2021
Fix open, if you care to take it for a spin @joseph-long: dask/dask-labextension#188
joseph-long commentedon May 19, 2021
Unrelated issue but following the development install instructions I ran in to this:
Had to
pip install jupyter-packagingmanually and then install worked.Anyway, I've been running the PR version for a few minutes now and CPU use is constant! Hooray!
ian-r-rose commentedon Jun 2, 2021
I've published a patch release of
dask-labextensionwhich avoids this behavior. It doesn't fix any underlying reference leaks on the scheduler, but should make it much less likely that users will run into them.A small reproducer for this which is independent of using JupyterLab:
In one terminal:
Run a small python script:
watch CPU for the process climb.
A fair criticism here is that this may not be the best way of checking alive-ness of the dashboard, and I would welcome other ideas :)
joseph-long commentedon Jun 3, 2021
It's like you read my mind. I was just checking in to see if the PR had made it into a release!
jrbourbeau commentedon Jun 3, 2021
Thanks @ian-r-rose! @joseph-long do you mind trying out the new
dask-labextensionrelease and letting us know if it fixes the issues you were seeing?jrbourbeau commentedon Jun 10, 2021
Closing this issue as being resolved by dask/dask-labextension#188. @joseph-long let us know if you want us to reopen
joseph-long commentedon Jun 10, 2021
Tried the new release and it worked for me, but forgot to comment. Thanks!