Skip to content

Kernel Finder workflow #11153

@rebornix

Description

@rebornix

This is part of the architecture review and refactoring task #10832 and majorly focused on kernel finding/detection.

The current workflow of finding kernels (10,000 feet view) is

  1. Extension activation / notebook document open
  2. Find Kernels
    • Find kernels from cache
      • Find kernels from remote server globalState
      • Find kernels from local kernel globalState
      • Validate Kernels from cache (async)
    • Update NotebookControllers
    • Find kernels without cache
      • Find kernels from remote server, reach out to the server
      • Find Kernels from local
        • Searches for kernels on the file system in well known paths documented by Jupyter
          • If we already search for it once, use that result (unless it's empty)
        • Returns all Python kernels and any related kernels registered in the python environment
          • Get interpreters from Python
          • Find python global python kernel specs and non python specs
    • Update NotebookControllers
  3. Listen to following events
    • Remote server Uri change
    • Remote kernel start/dispose
    • Extension change
    • Conda Environment change
    • Interpreters change
  4. When receive above events, run step 2.

As we register all the event listeners at a very top level, we accidentally trigger redundant kernel fetching requests. For example:

  • When a new kernel session is created on a remote server, we will run step 2, meaning we would try to find local python kernels without cache again.
  • When interpreters change, we would run step 2 again and send requests to remote server to fetch kernels/sessions

Also, when we re-run step 2, we always read cache first (which is asynchronous and not-zero-cost as it needs to validate all kernel specs) and then invalidate all caches. This makes sense on activation, but it's not necessary on event handling.

Metadata

Metadata

Labels

debtCode quality issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions