anaconda/nb_conda_kernels

Improving the latency of nb_conda_kernels

Closed this issue · 1 comments

Hello, this is a problem I ran into on a multi-user jupyterhub installed on a cluster with a shared conda install, I have a working solution but I am creating this issue to explain the problem.

The problem:

nb_conda_kernels needs to constantly call conda info to query the env list, however, under some conditions, a call to conda info can take multiple seconds or even more than 1 minute to execute, while it runs the jupyter backend is unresponsive and this is specially noticeable on a terminal running inside jupyterlab, where each keystroke needs a roundtrip to the server.

How to reproduce:

  1. edit <conda-path>/bin/conda and add these lines to simulate the delay:
import time
time.sleep(10)
  1. run jupyterlab (with nb_conda_kernels) and open a terminal
  2. type 1 letter per second and watch for freezes, happens every 2 minutes or so.

Proposed solution:

execute conda info in the background and lazily update the cache, this approach minimizes the time blocked at the price of having the cache not be as fresh.

I have a working implementation of this solution, tested on linux. I don't know about macos and windows.

fixed by #211