Slide 1

Slide 1 text

Why Wasm+WASI for Scala

Slide 2

Slide 2 text

2 Scala.js 1.17.0 supports experimental Wasm support! How does it help?

Slide 3

Slide 3 text

3 Scala.js 1.17.0 supports experimental Wasm support! How does it help? Almost nothing, yet :(

Slide 4

Slide 4 text

4 Is Wasm faster than JS? Wasm is indeed designed to be executed efficiently, but asking whether Wasm is faster than JavaScript is fundamentally a flawed question. Essentially, it depends on whether the compiler generates efficient JS or Wasm code, what kind of workload is, and on the implementation of the VM. Therefore, the accurate answer is that Wasm has the potential to be faster than JS, but whether it is generally faster depends on the implementation and workloads. Potentially yes, but it depends Long answer:

Slide 5

Slide 5 text

5 Is Wasm faster than JS? Potential future optimizations: - Optimization by wasm-opt - Remove unnecessary JS-interop

Slide 6

Slide 6 text

6 Wasm is NOT just about “faster code execution for Scala.js”

Slide 7

Slide 7 text

7 Wasm is about new features on browser And green-threads with stack-switching proposal in future Based on JSPI Wasm proposal

Slide 8

Slide 8 text

8 server-side Wasm is about sandboxing and fast-startup (and polyglot) Cloud is about sharing resources with other people on the large computers. Safe and efficient runtime isolation/virtualization is the key

Slide 9

Slide 9 text

9 History of isolation on Cloud ● VM (AWS EC2 / Google Compute Engine) ● VMM (Firecracker in AWS Lambda) ● Docker (runC?) ● gVisor (Cloud Run v1) ● Kata container ● V8 isolate (Cloudflare workers) ● WebAssembly

Slide 10

Slide 10 text

10 Li, Guoqing, et al. "Comparative Performance Study of Lightweight Hypervisors Used in Container Environment." CLOSER. 2021. gVisor-ptrace has better startup time, but it’s still around ~0.8s (and intercepting syscall reduces syscall latency)

Slide 11

Slide 11 text

11 WasmVM can start-up in milliseconds

Slide 12

Slide 12 text

12 Wasm+WASI can be a next “container”!