Skip to content

Pre warm raw kernel daemons #11487

Merged
DonJayamanne merged 33 commits into
microsoft:masterfrom
DonJayamanne:preWarmKernel
Apr 30, 2020
Merged

Pre warm raw kernel daemons #11487
DonJayamanne merged 33 commits into
microsoft:masterfrom
DonJayamanne:preWarmKernel

Conversation

@DonJayamanne
Copy link
Copy Markdown

@DonJayamanne DonJayamanne commented Apr 28, 2020

@rchiodo @IanMatthewHuff

  • Currently adding tests and some minor tweaks
  • Will update Wiki to document how interrupt and daemon work
  • Will fix functional tests.
  • Basically the way the daemon works is simple:
    • We start a python process and block on stdin
    • When we want to use a daemon, we write to the stdin, and thats when the actual ipykernel starts
    • Added comments in code (why it cannot be a separate thread - basically interrupt on windows doesn't work as it needs to be main thread).

* ipykernelInstaller:
  Add missing service
  Oops
  Typo
  Added tests
  Use separate class to manage kernel depedencies
  Ensure interrupt button is always enabled (#11461)
  Add collapsible sections to the bug issue template (#11462)
  Support ipywidgets in the kernel work (#11444)
  Ensure isolate script is passed as command arg when installing modules (#11447)
  Send LS version in static enabled/ready/startup events via lazy properties (#11448)
* master:
  Use separate class to manage kernel dependencies (#11472)
  Add ability to pass interpreter into kernel launcher (#11482)
  Use full path in argv to find interpreter matching a kernel (#11478)
  make sure we use our resource to get interpreter details (#11474)
  Handle failure to launch kernel while connecting (#11454)
  make raw kernel launch respect launching resource environment (#11463)
@codecov-io
Copy link
Copy Markdown

codecov-io commented Apr 28, 2020

Codecov Report

Merging #11487 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #11487   +/-   ##
=======================================
  Coverage   60.35%   60.35%           
=======================================
  Files         618      618           
  Lines       33751    33751           
  Branches     4762     4762           
=======================================
  Hits        20372    20372           
  Misses      12368    12368           
  Partials     1011     1011           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f6116b...8f6116b. Read the comment docs.

@DonJayamanne DonJayamanne added the no-changelog No news entry required label Apr 29, 2020
* master:
  Track notebook/interactive start dates (#11484)
  Merging back from release to master. (#11488)
@DonJayamanne DonJayamanne changed the title Pre warm kernel Pre warm raw kernel daemons Apr 29, 2020
@DonJayamanne DonJayamanne marked this pull request as ready for review April 29, 2020 19:01
* master:
  Adds missing entries in the unittest ioc container for extract var tests (#11493)
  Add debugger package root api. (#11464)
  Replace word "browse" with "find" (#11460)
  Route python interpreter into kernel launcher (#11486)
Comment thread src/client/datascience/kernel-launcher/kernelDaemonPool.ts
await daemonPool.preWarmKernelDaemons();

// Verify we only created 2 daemons.
verify(pythonExecutionFactory.createDaemon(anything())).twice();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like you're understanding implementation details. Would it be better to just check that the daemonPool object has 2 daemons running?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For that I need to expose the list, but i don't want to expose that list.
Its either expose the list for testing puproses or verify we called createDaemon twice.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the list, just a count

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need a team chat at some point about handling testing, especially post the testing talk that Graham gave? I'll confess to sometimes being a bit unsure about when I'm using verify in particular.

let daemon = await daemonPool.get(workspace1, kernelSpec, interpreter1);
assert.equal(daemon, instance(daemon1));
// Verify this daemon was pre-warmed.
verify(daemon1.preWarm()).atLeast(1);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preWarm [](start = 23, length = 7)

Same here, the daemon should have something to tell what state it is in. Like 'waiting for prewarm' or something. I think unit tests that know about internal details are brittle.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can expose a state, but thats only being used for testing purpose, which means we're adding API for testing alone (i.e. exposing internal test for testing purposes).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't that better than exposing the internal implementation details?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - prewarm is a public API.

await daemonPool.preWarmKernelDaemons();

// Verify we only created 2 daemons.
verify(pythonExecutionFactory.createDaemon(anything())).twice();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createDaemon [](start = 38, length = 12)

Yeah I guess it seems bad to me to verify all of these objects by inspecting their internal algorithm.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, we either expose a list of all created daemons for testing purposes or verify 2 were created.
I'm happy to go with the exposing of list for testing purposes if you're fine with that. However thats similar, as were exposing object internals for testing purposes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the difference between exposing private details and public. If we make the list (or maybe just the count) public, then we're committing to support that. Changes to this code later will know that it needs to keep that up to date. But if we change the internal details, we'll have to fix up a whole bunch of other stuff and these tests might not even work anymore.

Did you get a chance to read Grant's talk yet?


In reply to: 417633144 [](ancestors = 417633144)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you get a chance to read Grant's talk yet?

Yes, guess need to put it into practice and be more disciplined.

Copy link
Copy Markdown

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

* master:
  Support language servers that don't allow incremental doc updates (#11490)
Comment thread src/client/datascience/kernel-launcher/kernelDaemonPool.ts Outdated
}

// Finally create if needed
let resource: Resource = options.identity;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or this should use the actual resource that started the interactive window. I believe it used to. We might have messed it up when we created the notebook provider.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but looking at the code I could'nt find this being provided. I'll file an issue to ensure we pass this into NotebookProvider.
Originally it wasn't required, then we started using identity for the wrong reason.

@DonJayamanne DonJayamanne requested a review from rchiodo April 29, 2020 22:30
* master:
  Do not perform pipenv interpreter discovery on activation (#11369)
  Remove IJMPConnection and uses of it while maintaining same tests (#11503)
suppressShutdownErrors(this.realKernel);
return this.realKernel.shutdown().then(() => this.kernelProcess.dispose());
await this.kernelProcess.dispose();
this.socket.dispose();
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rchiodo @IanMatthewHuff Changed here as previous implementation would fall over.
We cannot call shutdown of the realKernel cuz it tries to make http call to jupyter.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but it just fails silently. I thought it also set state on itself. This would mean we're not setting that state.


In reply to: 417673182 [](ancestors = 417673182)

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.4% 0.4% Duplication

Copy link
Copy Markdown

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@DonJayamanne DonJayamanne merged commit 4cf109b into microsoft:master Apr 30, 2020
@DonJayamanne DonJayamanne deleted the preWarmKernel branch April 30, 2020 00:24
@lock lock Bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants