Skip to content

Commit

Permalink
experiment with webloops
Browse files Browse the repository at this point in the history
  • Loading branch information
e-nikolov committed Jan 23, 2024
1 parent 0f9876e commit 677bfec
Show file tree
Hide file tree
Showing 45 changed files with 2,561 additions and 1,080 deletions.
22 changes: 11 additions & 11 deletions .env
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# complete -o nospace -C /nix/store/zbzv9x7y2z690pj4kwpq1f4lak47w9f9-terraform-1.3.3/bin/terraform terraform

export TAILSCALE_API_KEY=op://personal/mpyc-demo/tailscale-api-token
export TAILSCALE_TAILNET=op://personal/mpyc-demo/tailscale-tailnet
export DIGITALOCEAN_TOKEN=op://personal/mpyc-demo/digitalocean-api-token
export AWS_ACCESS_KEY_ID=op://personal/mpyc-demo/digitalocean-spaces-key-id
export AWS_SECRET_ACCESS_KEY=op://personal/mpyc-demo/digitalocean-spaces-secret-access-key
export SPACES_ACCESS_KEY_ID=op://personal/mpyc-demo/digitalocean-spaces-key-id
export SPACES_SECRET_ACCESS_KEY=op://personal/mpyc-demo/digitalocean-spaces-secret-access-key
export TF_VAR_DOMAIN=demo.mpyc.tech
export G=test
export VITE_HTTPS_KEY=op://personal/mpyc-demo/tls-home-nix-key
export VITE_HTTPS_CERT=op://personal/mpyc-demo/tls-home-nix-crt
TAILSCALE_API_KEY=op://personal/mpyc-demo/tailscale-api-token
TAILSCALE_TAILNET=op://personal/mpyc-demo/tailscale-tailnet
DIGITALOCEAN_TOKEN=op://personal/mpyc-demo/digitalocean-api-token
AWS_ACCESS_KEY_ID=op://personal/mpyc-demo/digitalocean-spaces-key-id
AWS_SECRET_ACCESS_KEY=op://personal/mpyc-demo/digitalocean-spaces-secret-access-key
SPACES_ACCESS_KEY_ID=op://personal/mpyc-demo/digitalocean-spaces-key-id
SPACES_SECRET_ACCESS_KEY=op://personal/mpyc-demo/digitalocean-spaces-secret-access-key
TF_VAR_DOMAIN=demo.mpyc.tech
G=test
VITE_HTTPS_KEY=op://personal/mpyc-demo/tls-home-nix-key
VITE_HTTPS_CERT=op://personal/mpyc-demo/tls-home-nix-crt
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ if ! use flake . --impure; then
fi

if [ -f .env ]; then
source .env
dotenv
watch_file .env
fi
45 changes: 45 additions & 0 deletions benches/bnnmnist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Python 3.11


############################# bnnmnist/3 ##########################

mswsl1/native 00:27

mswin1/web/v0.6.0-c8b8d89/edge/debug 02:25
mswin1/web/v0.5.0-c8b8d89/edge/debug 01:32
mswin1/web/v0.4.0-76ca881/edge/debug 01:32
mswin1/web/v0.2.1-a51a93f/edge 02:10

mswin1/web/v0.6.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.5.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.4.0-76ca881/ffox/debug ??:??
mswin1/web/v0.2.1-a51a93f/ffox ??:??


############################# bnnmnist/1 #############################

mswsl1/native 00:21

mswin1/web/v0.6.0-c8b8d89/edge/debug 00:55
mswin1/web/v0.5.0-76ca881/edge/debug 00:58
mswin1/web/v0.4.0-76ca881/edge/debug 00:58
mswin1/web/v0.2.1-a51a93f/edge 01:57 / 02:00

mswin1/web/v0.6.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.5.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.4.0-76ca881/ffox/debug ??:??
mswin1/web/v0.2.1-a51a93f/ffox ??:??

############################# bnnmnist/0 #############################

mswsl1/native 00:13

mswin1/web/v0.6.0-c8b8d89/edge/debug 00:37
mswin1/web/v0.5.0-c8b8d89/edge/debug 00:39
mswin1/web/v0.4.0-76ca881/edge/debug 00:39
mswin1/web/v0.2.1-a51a93f/edge 00:39

mswin1/web/v0.6.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.5.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.4.0-76ca881/ffox/debug ??:??
mswin1/web/v0.2.1-a51a93f/ffox ??:??
147 changes: 147 additions & 0 deletions benches/cnnmnist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
Python 3.11


############################# cnnmnist/3 ##########################

mswsl1/native 02:25
mswin1/native 02:19
linux2/native 02:02

mswin1/web/v0.9.2-312c118(wl7)/chrm/debug 09:30
mswin1/web/v0.9.2-312c118(wl6)/chrm 08:40

mswin1/web/v0.9.2-312c118(wl6)/chrm/debug 09:46
mswin1/web/v0.9.2-312c118(wl6)/chrm 08:40

mswin1/web/v0.9.2-312c118(wl5)/chrm/debug 09:48
mswin1/web/v0.9.2-312c118(wl5)/chrm 08:13

mswin1/web/v0.9.2-312c118(wl4)/chrm/debug 09:54
mswin1/web/v0.9.2-312c118(wl4)/chrm 08:21

mswin1/web/v0.9.2-312c118(wl3)/chrm/debug 10:01
mswin1/web/v0.9.2-312c118(wl3)/chrm 08:40

mswin1/web/v0.9.2-e110e8c(owl3)/chrm/debug 09:50
mswin1/web/v0.9.2-e110e8c(owl3)/chrm 09:17

mswin1/web/v0.9.2-e110e8c(owl2)/chrm/debug 10:29 / 10:24 / 10:14
mswin1/web/v0.9.2-e110e8c(owl2)/chrm 08:46 / 12:00 / 09:06 / 09:18

mswin1/web/v0.9.2-03f1a8a(owl)/chrm/debug xx:xx - queueMicrotask deadlock after Barrier 1 0
mswin1/web/v0.9.2-03f1a8a(owl)/chrm xx:xx - queueMicrotask deadlock after Barrier 1 0,

mswin1/web/v0.7.0-d09e338/edge/full_async 30:00
mswin1/web/v0.7.0-d09e338/edge/full_call_soon 24:19
mswin1/web/v0.7.0-d09e338/edge 11:37
mswin1/web/v0.7.0-d09e338/edge/debug 11:59
mswin1/web/v0.5.0-d09e338/edge/debug 11:32 / 11:55
mswin1/web/v0.5.0-c8b8d89/edge/debug/console 25:51
mswin1/web/v0.4.0-76ca881/edge/debug 12:40 / 12:45
mswin1/web/v0.2.1-a51a93f/edge/debug 19:53 / 20:08

mswin1/web/v0.7.0-d09e338/ffox 12:17
mswin1/web/v0.7.0-d09e338/ffox/debug 13:16
mswin1/web/v0.5.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.4.0-76ca881/ffox/debug ??:??
mswin1/web/v0.2.1-a51a93f/ffox/debug ??:??

linux2/web/v0.7.0-d09e338/edge 13:15
linux2/web/v0.7.0-d09e338/edge/debug 13:51 / 14:12 / 13:54
linux2/web/v0.5.0-c8b8d89/edge/debug 14
linux2/web/v0.4.0-76ca881/edge/debug ??:??
linux2/web/v0.2.1-a51a93f/edge/debug ??:??

linux2/web/v0.7.0-d09e338/ffox/debug/full_async 36:00
linux2/web/v0.7.0-d09e338/ffox/debug 16:00 / 16:59
linux2/web/v0.5.0-c8b8d89/ffox/debug 19:44 / 20:42 / 20:49
linux2/web/v0.5.0-c8b8d89/ffox/debug/10/100 36:00
linux2/web/v0.4.0-76ca881/ffox/debug 23:38
linux2/web/v0.2.1-a51a93f/ffox/debug ??:??


mswin1/web/v0.5.0-c8b8d89/edge/dev 10:22
mswin1/web/v0.5.0-c8b8d89/edge ??:??

############################# cnnmnist/1 #############################

mswsl1/native 01:21
mswin1/native 01:20
linux2/native 01:06


mswin1/web/v0.9.2-312c118(wl3)/chrm/debug 04:08
mswin1/web/v0.9.2-312c118(wl3)/chrm 03:56

mswin1/web/v0.9.2-e110e8c(owl3)/chrm/debug 03:36
mswin1/web/v0.9.2-e110e8c(owl3)/chrm 03:38

mswin1/web/v0.9.2-e110e8c(owl2)/chrm/debug 03:40
mswin1/web/v0.9.2-e110e8c(owl2)/chrm 03:47

mswin1/web/v0.9.2-03f1a8a(owl)/chrm/debug 03:38
mswin1/web/v0.9.2-03f1a8a(owl)/chrm 03:43

mswin1/web/v0.5.0-c8b8d89/edge/debug 05:17
mswin1/web/v0.4.0-76ca881/edge/debug 05:18
mswin1/web/v0.2.1-a51a93f/edge 05:57

mswin1/web/v0.5.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.4.0-76ca881/ffox/debug ??:??
mswin1/web/v0.2.1-a51a93f/ffox/debug ??:??

linux2/web/v0.5.0-c8b8d89/edge/debug 05:20
linux2/web/v0.4.0-76ca881/edge/debug 05:34
linux2/web/v0.2.1-a51a93f/edge 06:13

linux2/web/v0.5.0-c8b8d89/ffox/debug 06:02 / 05:52 / 05:46
linux2/web/v0.4.0-76ca881/ffox/debug 06:24 / 06:17
linux2/web/v0.2.1-a51a93f/ffox 06:04






mswin1/web/v0.5.0-c8b8d89/edge/desktop-win 05:15
mswin1/web/v0.5.0-c8b8d89/edge/desktop-win/dev 05:11


############################# cnnmnist/1/no async #############################

mswsl1/native 00:26
mswin1/native 00:27
linux2/native 00:24

mswin1/web/v0.9.2-312c118(wl3)/chrm/debug 01:38
mswin1/web/v0.9.2-312c118(wl3)/chrm 01:39

mswin1/web/v0.9.2-e110e8c(owl3)/chrm/debug 01:38
mswin1/web/v0.9.2-e110e8c(owl3)/chrm 01:36

mswin1/web/v0.9.2-e110e8c(owl2)/chrm/debug 01:36
mswin1/web/v0.9.2-e110e8c(owl2)/chrm 01:36

mswin1/web/v0.9.2-03f1a8a(owl)/chrm/debug 01:43
mswin1/web/v0.9.2-03f1a8a(owl)/chrm 01:45

mswin1/web/v0.5.0-c8b8d89/edge/debug 01:35
mswin1/web/v0.4.0-76ca881/edge/debug 01:38
mswin1/web/v0.2.1-a51a93f/edge 01:33

mswin1/web/v0.5.0-c8b8d89/ffox/debug ??:??
mswin1/web/v0.4.0-76ca881/ffox/debug ??:??
mswin1/web/v0.2.1-a51a93f/ffox/debug ??:??

linux2/web/v0.5.0-c8b8d89/edge/debug ?????
linux2/web/v0.4.0-76ca881/edge/debug 01:43
linux2/web/v0.2.1-a51a93f/edge ?????

linux2/web/v0.5.0-c8b8d89/ffox/debug 01:34 / 01:20
linux2/web/v0.4.0-76ca881/ffox/debug 01:41 / 01:21
linux2/web/v0.2.1-a51a93f/ffox 01:21 / 01:21



mswin1/web/v0.5.0-c8b8d89/edge/dev 01:34
mswin1/web/v0.5.0-c8b8d89/edge 01:36
66 changes: 66 additions & 0 deletions benches/secretsanta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Python 3.11


############################# secretsanta/3 ##########################

mswsl1/native 00:01.5
mswin1/native 00:01.8


mswin1/web/v0.9.2-312c118(wl3)/chrm/debug 00:10
mswin1/web/v0.9.2-312c118(wl3)/chrm 00:07

mswin1/web/v0.9.2-e110e8c(owl3)/chrm/debug 00:09.7
mswin1/web/v0.9.2-e110e8c(owl3)/chrm 00:09.1

mswin1/web/v0.9.2-e110e8c(owl2)/chrm/debug 01:47
mswin1/web/v0.9.2-e110e8c(owl2)/chrm 01:41

mswin1/web/v0.9.2-03f1a8a(owl)/chrm/debug 00:05
mswin1/web/v0.9.2-03f1a8a(owl)/chrm 00:05

mswin1/web/v0.6.0-3b0f9d4/chrm/debug 00:14
mswin1/web/v0.2.1-a51a93f/chrm/debug 00:22

############################# secretsanta/1 #############################

mswsl1/native 00:00.7
mswin1/native 00:00.8


mswin1/web/v0.9.2-312c118(wl3)/chrm/debug 00:02.4
mswin1/web/v0.9.2-312c118(wl3)/chrm 00:02.7

mswin1/web/v0.9.2-e110e8c(owl3)/chrm/debug 00:02.5
mswin1/web/v0.9.2-e110e8c(owl3)/chrm 00:02.5

mswin1/web/v0.9.2-e110e8c(owl2)/chrm/debug 01:19
mswin1/web/v0.9.2-e110e8c(owl2)/chrm 01:12

mswin1/web/v0.9.2-03f1a8a(owl)/chrm/debug 00:01.7
mswin1/web/v0.9.2-03f1a8a(owl)/chrm 00:01.7

mswin1/web/v0.6.0-3b0f9d4/chrm/debug 00:04
mswin1/web/v0.2.1-a51a93f/chrm/debug 00:04

############################# secretsanta/1/no async #############################

mswsl1/native 00:00.5
mswin1/native 00:00.5


mswin1/web/v0.9.2-312c118(wl3)/chrm/debug 00:01
mswin1/web/v0.9.2-312c118(wl3)/chrm 00:01

mswin1/web/v0.9.2-e110e8c(owl3)/chrm/debug 00:01
mswin1/web/v0.9.2-e110e8c(owl3)/chrm 00:01

mswin1/web/v0.9.2-e110e8c(owl2)/chrm/debug 00:01
mswin1/web/v0.9.2-e110e8c(owl2)/chrm 00:01

mswin1/web/v0.9.2-03f1a8a(owl)/chrm/debug 00:01
mswin1/web/v0.9.2-03f1a8a(owl)/chrm 00:00.9


mswin1/web/v0.6.0-3b0f9d4/chrm/debug 00:01
mswin1/web/v0.2.1-a51a93f/chrm/debug 00:01
12 changes: 11 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,14 @@ patch dep version='':
"{{justfile_directory()}}/scripts/patch-{{dep}}.sh" {{if version == "" { "" } else { "@" } }}{{version}}

build:
yarn build
yarn build

devs2:
WSLENV=$WSLENV:VITE_HTTPS_KEY:VITE_HTTPS_CERT op.exe run --env-file="./.env" -- wsl env | grep VITE

devs:
WSLENV=$WSLENV:VITE_HTTPS_KEY:VITE_HTTPS_CERT:PATH/p op.exe run --no-masking --env-file="./.env" -- wsl.exe -- VITE_HTTPS=true yarn dev

watch:
# wsl.exe -- nix develop --impure -c -- yarn vite --debug
WSLENV=$WSLENV:VITE_HTTPS_KEY:VITE_HTTPS_CERT:PATH wsl.exe -- yarn vite --debug
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class PyScriptWorkerRuntime extends MPCRuntimeBase {
console.log(self.pyodide)
// wrap.interpreter.setStdin(true)
// wrap.interpreter.setStdout(true)
wrap.interpreter.setDebug(true)

self.runAsync = async (code: string, filename: string) => {
try {
Expand All @@ -91,34 +92,6 @@ export class PyScriptWorkerRuntime extends MPCRuntimeBase {
}
};

// const oldSetTimeout = self.setTimeout

// const setTimeoutFromSetImmediate = (setImmediate: (cb: () => void) => void) => (callback: () => never, delay: number = 0) => {
// if (delay < 1) {
// return setImmediate(callback)
// } else {
// return oldSetTimeout(callback, delay);
// }
// }

// self.counter = 0;
// var queue = {};

// var channel = new MessageChannel();

// channel.port1.onmessage = function (event) {
// var callback = queue[event.data];
// delete queue[event.data];
// callback();
// };

// const setImmediate = (callback: () => void) => {
// queue[++self.counter] = callback;
// channel.port2.postMessage(self.counter);
// }

// self.fastSetTimeout = setTimeoutFromSetImmediate(setImmediate)
// self.setTimeout = self.fastSetTimeout;
// self.runAsync(wrap, startup, { filename: "startup.py" })
self.runAsync(`
import asyncio
Expand Down Expand Up @@ -157,7 +130,5 @@ declare global {
interface Window {
runAsync: (code: string, filename: string) => Promise<any>;
counter: number;
fastSetTimeout: (callback: () => never, delay: number) => void;
setTimeout: any
}
}
4 changes: 2 additions & 2 deletions mpyc-web-core/lib/transports/PeerJS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export class PeerJSTransport extends Emittery<TransportEvents> implements Transp
// debug: 3,
// secure: true,
secure: true,
host: "mpyc-demo--headscale-ams3-c99f82e5.demo.mpyc.tech",
port: 443,
// host: "mpyc-demo--headscale-ams3-c99f82e5.demo.mpyc.tech",
// port: 443,
config: {
iceServers: [
{ urls: "stun:stun.l.google.com:19302" },
Expand Down
1 change: 0 additions & 1 deletion mpyc-web-core/types/runtimes/PyScriptWorkerRuntime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ export declare class PyScriptWorkerRuntime extends MPCRuntimeBase {
declare global {
interface Window {
runAsync: any;
fastSetTimeout: (callback: () => never, delay: number) => void;
}
}
2 changes: 2 additions & 0 deletions mpyc-web-demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ <h5> MPC Demos: </h5>
<option value="./py/benches/test.py">Benchmarks - test</option>
<option value="./py/benches/calls.py">Benchmarks - function calls</option>
<option value="./py/benches/timers.py">Benchmarks - timers</option>
<option value="./py/benches/stats.py">Benchmarks - stats</option>
<option value="./py/benches/proxies.py">Benchmarks - proxies</option>
<option value="./py/features/plots.py">Features - plots 1</option>
<option value="./py/features/plots2.py">Features - plots 2</option>
</select>
Expand Down
2 changes: 1 addition & 1 deletion mpyc-web-demo/src/ts/app/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class Controller {

this.resetPeerIDButton.addEventListener('click', async () => { app.deleteTabState("myPeerID"); this.term.writeln("Restarting PeerJS..."); mpyc.resetTransport(() => new PeerJSTransport()); });
this.stopMPyCButton.addEventListener('click', async () => { this.term.writeln("Restarting PyScript runtime..."); mpyc.resetRuntime(); });
this.runMPyCButton.addEventListener('click', async (ev) => { this.term.scrollToBottom(); mpyc.runMPC(this.editor.getCode(), this.demoSelect.value, ev.ctrlKey || ev.shiftKey); });
this.runMPyCButton.addEventListener('click', async (ev) => { this.term.scrollToBottom(); mpyc.runMPC(this.editor.getCode(), this.demoSelect.value, ev.ctrlKey || ev.shiftKey); this.term.scrollToBottom(); });
this.connectToPeerButton.addEventListener('click', async () => { localStorage.hostPeerID = this.hostPeerIDInput.value; mpyc.transport.connect(this.hostPeerIDInput.value) });
this.sendMessageButton.addEventListener('click', async () => { this.sendChatMessage(); });
this.clearTerminalButton.addEventListener('click', async () => { this.term.clear(); });
Expand Down
Loading

0 comments on commit 677bfec

Please sign in to comment.