Skip to content
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

Use sendBeacon to send kernel shutdown request. #972

Merged
merged 5 commits into from
Sep 22, 2021

Conversation

trungleduc
Copy link
Member

@trungleduc trungleduc commented Sep 19, 2021

References

Support for synchronous use of XMLHTTPRequest() during page unloads is removed from Chrome (https://www.chromestatus.com/feature/4664843055398912).

Code changes

Use sendBeacon to send kernel shutdown request on beforeunload event

User-facing changes

N/A

Backwards-incompatible changes

N/A

@github-actions
Copy link
Contributor

github-actions bot commented Sep 19, 2021

Benchmark report

The execution time (in milliseconds) are grouped by test file, test type and browser.
For each case, the following values are computed: min <- [1st quartile - median - 3rd quartile] -> max.

Results table
Test file basics.ipynb bqplot.ipynb dashboard.ipynb gridspecLayout.ipynb interactive.ipynb ipympl.ipynb ipyvolume.ipynb multiple_widgets.ipynb query-strings.ipynb
Render
chromium
actual 2619 <- [2702 - 2783 - 2956] -> 3459 2473 <- [2525 - 2617 - 2666] -> 2785 2586 <- [2637 - 2650 - 2665] -> 2795 3146 <- [3160 - 3171 - 3221] -> 3224 1872 <- [1896 - 1905 - 1975] -> 2036 2553 <- [2589 - 2611 - 2681] -> 2758 8847 <- [10887 - 11787 - 14680] -> 15052 9442 <- [9468 - 9509 - 9539] -> 9692 1180 <- [1204 - 1278 - 1286] -> 1308
expected 3379 <- [3442 - 3517 - 3701] -> 3876 2976 <- [3227 - 3321 - 3421] -> 3604 3608 <- [3623 - 3709 - 3793] -> 3825 4453 <- [4453 - 4523 - 4661] -> 4748 2559 <- [2655 - 2656 - 2660] -> 2674 3982 <- [4079 - 4213 - 4356] -> 4743 12183 <- [18509 - 19553 - 20811] -> 21515 15319 <- [15660 - 15796 - 15912] -> 16056 1517 <- [1920 - 1997 - 2103] -> 2113

❗ Test metadata have changed
--- /dev/fd/63	2021-09-21 20:48:39.610714122 +0000
+++ /dev/fd/62	2021-09-21 20:48:39.614714197 +0000
@@ -8,27 +8,27 @@
   },
   "systemInformation": {
     "cpu": {
-      "brand": "Xeon® Platinum 8272CL",
+      "brand": "Xeon® E5-2673 v3",
       "cache": {
         "l1d": 65536,
         "l1i": 65536,
-        "l2": 2097152,
-        "l3": 36700160
+        "l2": 524288,
+        "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 mpx avx512f avx512dq rdseed adx smap clflushopt avx512cd avx512bw avx512vl xsaveopt xsavec xsaves 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": "85",
+      "model": "63",
       "physicalCores": 2,
       "processors": 1,
       "revision": "",
       "socket": "",
-      "speed": 2.6,
+      "speed": 2.4,
       "speedMax": null,
       "speedMin": null,
-      "stepping": "7",
+      "stepping": "2",
       "vendor": "GenuineIntel",
       "virtualization": false,
       "voltage": ""
@@ -42,11 +42,11 @@
       "codename": "Focal Fossa",
       "codepage": "UTF-8",
       "distro": "Ubuntu",
-      "kernel": "5.8.0-1041-azure",
+      "kernel": "5.8.0-1040-azure",
       "logofile": "ubuntu",
       "platform": "linux",
       "release": "20.04.3 LTS",
-      "serial": "faac5b9e00cf4ae3b2d2c013e98d933a",
+      "serial": "cfc067bfcb844f35865e279a1b0e66c5",
       "servicepack": "",
       "uefi": false
     }

@jtpio
Copy link
Member

jtpio commented Sep 20, 2021

Thanks @trungleduc.

Re-reading the discussion in #612, I think the original intent was to be able to set that flag to false so the request doesn't get aborted in the middle of the page unload.

@jtpio
Copy link
Member

jtpio commented Sep 20, 2021

is removed from Chrome (https://www.chromestatus.com/feature/4664843055398912)

Given this:

"While this is reasonable, there are no good reasons to use synchronous XHR. Instead SendBeacon, Fetch keep-alive should be used (in addition to sending analytics periodically and on pagevisibility etc.)."

Maybe we should give another look at using sendBeacon which was experimented with in #612 (comment)

@trungleduc
Copy link
Member Author

Thanks @jtpio, sorry for didn't read the discussion in #612 before. I'll open an issue and try the sendBeacon with this PR

@trungleduc trungleduc marked this pull request as draft September 20, 2021 08:29
@trungleduc trungleduc linked an issue Sep 20, 2021 that may be closed by this pull request
@jtpio jtpio added the bug Something isn't working label Sep 20, 2021
@trungleduc trungleduc marked this pull request as ready for review September 20, 2021 21:15
@trungleduc trungleduc changed the title Switch to asynchronous XMLHttpRequest. Use sendBeacon to send kernel shutdown request. Sep 20, 2021
@jtpio jtpio added this to the 0.2.x milestone Sep 21, 2021
@jtpio
Copy link
Member

jtpio commented Sep 21, 2021

Thanks!

Testing on Binder with this link:

https://mybinder.org/v2/gh/trungleduc/voila/fix-kernel-shutdown?urlpath=voila%2Ftree%2Fnotebooks

It looks like the request is correctly sent, but returns a 405:

send-beacon-binder.mp4

Not sure if it's a limitation on the Binder side. Voila runs as a server extension there and the diff looks good w.r.t that.

@trungleduc
Copy link
Member Author

It looks like the POST URL https://hub.gke2.mybinder.org/voila/api/shutdown/... is not correct since Voila server is exposed at https://hub.gke2.mybinder.org/user/trungleduc-voila-mxw256mu/. It should send request to something like https://hub.gke2.mybinder.org/user/trungleduc-voila-mxw256mu/voila/api/shutdown/... to make it works

@jtpio
Copy link
Member

jtpio commented Sep 21, 2021

Ah good catch, then that would explain why.

voila/app.py Show resolved Hide resolved
@trungleduc
Copy link
Member Author

it seems to work now in Binder

voila

Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

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

Thanks @trungleduc!

@jtpio jtpio merged commit f154024 into voila-dashboards:main Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kernel shutdown request is failed to send on page refresh or closed
2 participants