-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pooling heated kernels and pre-rendered notebook #936
Add pooling heated kernels and pre-rendered notebook #936
Conversation
Ping @SylvainCorlay @maartenbreddels. Can you have a look at this? |
Thanks @trungleduc for starting this, it looks very promising! |
Would you mind adding some details about how this compares to https://github.com/voila-dashboards/hotpot_km/ ? (i.e. what extra functionality does this add; are there any functionality missing, etc). |
Actually I based on
|
55ce8df
to
67c889d
Compare
Benchmark reportThe execution time (in milliseconds) are grouped by test file, test type and browser. Results table
❗ Test metadata have changed--- /dev/fd/63 2021-10-04 17:44:28.991310708 +0000
+++ /dev/fd/62 2021-10-04 17:44:28.991310708 +0000
@@ -8,27 +8,27 @@
},
"systemInformation": {
"cpu": {
- "brand": "Xeon® E5-2673 v4",
+ "brand": "Xeon® E5-2673 v3",
"cache": {
"l1d": 65536,
"l1i": 65536,
"l2": 524288,
- "l3": 52428800
+ "l3": 31457280
},
"cores": 2,
"family": "6",
- "flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt md_clear",
+ "flags": "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt md_clear",
"governor": "",
"manufacturer": "Intel®",
- "model": "79",
+ "model": "63",
"physicalCores": 2,
"processors": 1,
"revision": "",
"socket": "",
- "speed": 2.3,
+ "speed": 2.4,
"speedMax": null,
"speedMin": null,
- "stepping": "1",
+ "stepping": "2",
"vendor": "GenuineIntel",
"virtualization": false,
"voltage": ""
@@ -42,11 +42,11 @@
"codename": "Focal Fossa",
"codepage": "UTF-8",
"distro": "Ubuntu",
- "kernel": "5.8.0-1042-azure",
+ "kernel": "5.8.0-1040-azure",
"logofile": "ubuntu",
"platform": "linux",
"release": "20.04.3 LTS",
- "serial": "487dcaac68944409a00596acdb9a6fc0",
+ "serial": "cfc067bfcb844f35865e279a1b0e66c5",
"servicepack": "",
"uefi": false
} |
1df6448
to
1949d18
Compare
Thanks @trungleduc for pushing on this. Looks like there is a small conflict to fix. |
188dd36
to
74a9b9a
Compare
Could it be related to the new |
Or we update the screenshot with the one generated on CI? |
In this case the local test won't pass |
Right, but I think the common practice is to use the ones generated on CI as reference since this is where the checks are running. Or use Docker like in the JupyterLab repo to minimize differences, although that would complicate the setup. |
By the way, this PR is looking good and promising. Adding to the @vidartf @maartenbreddels would you like to give it a quick review since you have been doing similar work on |
acd182f
to
9c63e02
Compare
9d5da33
to
2ea8abd
Compare
Thanks @trungleduc for working on this. Let me know if you would like to push more changes. Otherwise we can wait for the tests to pass, merge, and release cc @SylvainCorlay as the |
@jtpio I'm figuring out why the test |
OK thanks for heads-up 👍 Feel free to ping here when you think it's ready. |
@jtpio It's all green now 😄 |
🎉 |
Cutting |
New features
This PR aims to accelerate the startup time of Voila by adding two features:
Pooling pre-heated kernels
Voila
started with is executed in every kernel of the pool.hotpot_km
. Some code snippets of this PR are taken from this library with permission of the author.Pre-rendered notebook
Voila
, under some conditions, the cached HTML is served instead of re-rendering the notebook.How it works
When Voila started with
preheat_kernel=True
, it will create multipleasyncio.Task
for each notebook. Each task will start a kernel and execute the notebook in this kernel. Voila keeps a mapping of notebook name to the list of tasks started for this notebook. Each task will return a tuple which contains a list HTML string of rendered cells and an async generator which can be used to render the remaining cells.As depicted in the image below, the content of elements in this tuple depends on the moment
Voila
receives a request:Voila
will get the HTML string of all cells then send to frontend.Voila
will pick the first started kernel and send the rendered cell to frontend while executing the remaining.Speed comparison
voila.mp4
-With a partially executed notebook
voilahp.mp4
Current status
The pre-heat kernel option works with any kernel manager, it is deactivated by default, re-activate it by setting
preheat_kernel = True
. For example, with this command, for each notebook Voilà started with, a pool of 5 kernels is created and will be used for new connections.To change the additional settings ( list of notebooks does not need pre-heated kernels, number of kernels in pool, refilling delay, environment variables for starting kernel...), users can use
voila.json
configuration file in the same folder containing the notebooks. Here is an example of settings with explanations for pre-heat kernel option.Notebook HTML will be pre-rendered with template and theme defined in VoilaConfiguration or in notebook metadata. The pre-heated kernel and cached HTML are used if these conditions are matched:
voila-theme
andvoila-template
.If the kernel pool is empty or the request does not match these conditions, Voila will fail back to start a normal kernel and render the notebook as usual.
Code changes
VoilaHandler
: the notebook rendering part ofVoilaHandler
is extracted as a new classNotebookRenderer
, this class is used to render notebook in both voila handler and pre-heated kernelvoila_kernel_manager_factory
to decorate the kernel manager class defined inVoilaConfiguration.multi_kernel_manager_class
with pooling featurespreheat_kernel
andpool_size
to Voila application to set up kernel pool.Backwards-incompatible changes
Aside
VoilaHandler
refactoring, the notable changes come from this PR are:--preheat_kernel
andpool_size
toVoila
CLIVoila
with the preheat features ifpreheat_kernel=True
.Since
preheat_kernel
is set toFalse
by defaut, we should not have any breaking changes with0.2.x