Slide 1

Slide 1 text

Licensed http://clipart-library.com/clip-art/94-943337_star-wars-quotes-yoda-star-wars-humor-sea.htm

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

New Language for the Web

Slide 4

Slide 4 text

HTML / CSS / JS Since 1996, HTML, CSS, and Javascript languages for the Web

Slide 5

Slide 5 text

HTML / CSS / JS / WASM Following HTML, CSS and JavaScript, WebAssembly becomes the fourth language for the Web which allows code to run in the browser in 2019

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Low-Level Language

Slide 9

Slide 9 text

HTML / CSS / JS Structure Style Language

Slide 10

Slide 10 text

HTML Structure Web Application h1 { display: flex; width: 100%; font-size: 3em; color: red; }

Hello World

Say Hi WebAssembly.instantiateStreaming( fetch("add.wasm") ).then(module => { const { add } = module.instance.exports; document .querySelector("button") .addEventListener("click", () => { alert(`10 + 10 = ${add(10, 10)}`) }); });

Slide 11

Slide 11 text

CSS Style Web Application h1 { display: flex; width: 100%; font-size: 3em; color: red; }

Hello World

Say Hi WebAssembly.instantiateStreaming( fetch("add.wasm") ).then(module => { const { add } = module.instance.exports; document .querySelector("button") .addEventListener("click", () => { alert(`10 + 10 = ${add(10, 10)}`) }); });

Slide 12

Slide 12 text

Javascript High-level Language Web Application h1 { display: flex; width: 100%; font-size: 3em; color: red; }

Hello World

Say Hi WebAssembly.instantiateStreaming( fetch("add.wasm") ).then(module => { const { add } = module.instance.exports; document .querySelector("button") .addEventListener("click", () => { alert(`10 + 10 = ${add(10, 10)}`) }); });

Slide 13

Slide 13 text

HTML / CSS / JS / WASM Structure Style High Level Language Low Level Language

Slide 14

Slide 14 text

- https://www.youtube.com/watch?v=TGo3vJVTlyQ

Slide 15

Slide 15 text

- https://www.youtube.com/watch?v=TGo3vJVTlyQ

Slide 16

Slide 16 text

WASM Low-level Language Web Application h1 { display: flex; width: 100%; font-size: 3em; color: red; }

Hello World

Say Hi WebAssembly.instantiateStreaming( fetch("add.wasm") ).then(module => { const { add } = module.instance.exports; document .querySelector("button") .addEventListener("click", () => { alert(`10 + 10 = ${add(10, 10)}`) }); });

Slide 17

Slide 17 text

WASM Low-level Language // c int add(int x, int y) { return x + y; } // rust fn add (x: u32, y: u32) -> u32 { x + y } // AssemblyScript function add(x: i32, y: i32): i32 { return x + y; }

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Run with near-native - Predictable performance - Optimized for fast load and execution - Efficient memory management - Use 'better' language to solve a certain problem

Slide 21

Slide 21 text

High-Level Low-Level - Less slow than - Runtime optimization - Loose memory management - Runtime error - Promised performance - Efficient memory management - Rooms for performance improvement - Reuse popular libraries - Easy to learn, low learning curve - No compile and build - No need for memory management 👎 👍 👍 👎 - Hard to learn - Compile and build to run - Difficult memory management - Poor programming productivity

Slide 22

Slide 22 text

Lin: "ݢ੷ Javascript ৬ WebAssembly प೯ غח җ੿ਸ ঌইࠁ੗" "ೞ੉" "п ߄ח যڃ ੘সਸ ೞח૑ ࠁৈ઻" https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/

Slide 23

Slide 23 text

Lin: "Javascript ূ૓੄ प೯ җ੿ ੉Ҋ" Lin: "WebAssembly ূ૓੄ प೯ җ੿" "ٯ ࠊب प೯ө૑ җ੿੉ рױೞ૑" https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/

Slide 24

Slide 24 text

WebAssembly: "դ ੉޷ Bytecode, ղ ௏٘ Ѥٜ૑݃" Javascript: "ݢ੷ ౵य೧ࢲ AST ٜ݅Ҋ, ੗.. ೙ਃೠѱ ޤջ ࠁ੗ https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/

Slide 25

Slide 25 text

WebAssembly: "੉޷ प೯ী ೙ਃೠ Ѥ ળ࠺ ৮ܐ!" Javascript: "ࡅܰѱ प೯ ೞ۰ݶ ೙ਃೠ Ѣ ݢ੷" "ա઺ী ஹ౵ੌ, ୭੸ച ب ׮द׮द" https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/

Slide 26

Slide 26 text

WebAssembly: "੿੸ ఋੑ ࢎਊ, JIT ח ೡੌ੉ হਸѦ" Javascript: "ਃѢ ׮द ୭੸ച ೧ঠ ೡ ٠, Ӓ ఋੑ੉ ইפ֎" https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/

Slide 27

Slide 27 text

Javascript: "ש ௏٘ ಁఢҗ JIT ש ٮۄ प೯੉ ׳ۄ૗. ഷ" WebAssembly: "زੌ ߄੉ցܻ (Ѣ੄) زੌ ࢿמ" https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/

Slide 28

Slide 28 text

https://hacks.mozilla.org/2017/02/what-makes-webassembly-fast/ Javascript: "୒ࣗ઺. प೯ ୹ੑ Ә૑" WebAssembly: "୒ࣗ? ই૒਷ ݽܴ"

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Javascript
 Source Code Ignition
 (JS Interpreter) TurboFan
 (Optimization Compiler) Optimized
 Machine
 Code Deoptimize Javascript Pipeline Parse Bytecode BlinkOn 6 Day 1 Talk 2: Ignition - an interpreter for V8 - YouTube / https://www.youtube.com/watch?v=r5OWCtuKiAk

Slide 31

Slide 31 text

https://mathiasbynens.be/notes/prototypes#tradeoffs Javascript Pipeline

Slide 32

Slide 32 text

Liftoff
 (WebAssembly baseline compiler) Hot Swap Execution
 Immediately WASM TurboFan
 (Optimization Compiler) Off-thread
 Optimization WebAssembly Pipeline https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 33

Slide 33 text

Implicit Caching Liftoff
 (WebAssembly baseline compiler) Hot Swap Execution
 Immediately WASM TurboFan
 (Optimization Compiler) Off-thread
 Optimization HTTP Cache Loads Optimized Module https://www.youtube.com/watch?v=kZrl91SPSpc New Session

Slide 34

Slide 34 text

Using Implicit Caching https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

https://developers.google.com/web/updates/2019/02/hotpath-with-wasm

Slide 39

Slide 39 text

https://www.youtube.com/watch?v=Yo83yhRN_Ss

Slide 40

Slide 40 text

https://www.youtube.com/watch?v=Yo83yhRN_Ss

Slide 41

Slide 41 text

Javascript WebAssembly - Compiles, and builds to run - Optimized performance - Promised predictable performance - Efficient memory management - Easy to code and run - Less slow than - High cost for peak performance - Better experience in DOM/Web APIs - Make a small or simple code - Code and check the result often - Call a DOM, Web APIs frequently - Make a hot-path code

Slide 42

Slide 42 text

- Different to Grandma's VM - Virtual Instruction Set Architecture (V-ISA) - Written in a variety of languages, C/C++, Rust, Go, AssemblyScript, ... - Linear Memory, Implicit Stack, Some Instructions - No operation system access and built-in functions - Running on trusted runtimes, V8, SpiderMonkey, Wasmtime, Lucet, WAMR, Cranelift, ... Virtual Machine

Slide 43

Slide 43 text

(module (func $add (param $x i32) (param $y i32) (result i32) get_local $x get_local $y i32.add) (export "add" (func $add)) ) WebAssembly Instructions 0 (i32, i32) -> (i32) 1 (i64, i64) -> (i64) 0 Type 0 1 Type 1 0 Code for Function 0 1 Code for Function 1 $add Export Type Function Code map memory 0 of 1 i32.add get_local $y get_local $x 0 1 3 4 5 6 8 2 7 ArrayBuffer Module 9 0 2 3 4 5 7 1 6 8 Push Pop 0 "$add", Function 0 1 "$add64", Function 1 Memory 0 1 2 3 4 1 2 3 i32.store i32.load

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

https://hacks.mozilla.org/2017/07/memory-in-webassembly-and-why-its-safer-than-you-think/ Host: "ݫݽܻ (ArrayBuffer) ખ ઱ࣁਃ" "࢜ WASM ੉ ৳যਃ" "ೞ੉ ژ աঠ"

Slide 46

Slide 46 text

WASM: "࢜۽ ৳ਵפ ੋࢎ ೧ঠ૑ Hello ܳ ࠁղ੗" https://hacks.mozilla.org/2017/07/memory-in-webassembly-and-why-its-safer-than-you-think/

Slide 47

Slide 47 text

WASM: "ղ ݫݽܻ 0 ߣ ࠗఠ 'H', 'e', 'l', ',l', 'o' ੸যঠ૑
 0 ী 01001000, 1 ী 01100101, 2 ী 01101100 ... " https://hacks.mozilla.org/2017/07/memory-in-webassembly-and-why-its-safer-than-you-think/

Slide 48

Slide 48 text

Host: "Hello ۄ... ੋࢎࢿ੉ જ֎, ݈਷ ૣҊ" https://hacks.mozilla.org/2017/07/memory-in-webassembly-and-why-its-safer-than-you-think/

Slide 49

Slide 49 text

WASM: "0 ~ 9 ө૑о ࠽ܽѢ" https://hacks.mozilla.org/2017/07/memory-in-webassembly-and-why-its-safer-than-you-think/

Slide 50

Slide 50 text

WASM: "աݠ૑ח դ ݽܴ" "੽Ӕೞ૑ ޅೣ" https://hacks.mozilla.org/2017/07/memory-in-webassembly-and-why-its-safer-than-you-think/

Slide 51

Slide 51 text

"WASM о աщਵפ ஖ਕঠ૑" Host: "Әߑ աщ֎" https://hacks.mozilla.org/2017/07/memory-in-webassembly-and-why-its-safer-than-you-think/

Slide 52

Slide 52 text

Taking advantages from Low-level languages - Multi-thread - SIMD - Multi-language - Reuse popular libraries wide spread

Slide 53

Slide 53 text

SharedArrayBuffer Worker1 CPU Core WASM Instance Worker2 CPU Core WASM Instance Worker3 CPU Core WASM Instance https://www.youtube.com/watch?v=kZrl91SPSpc atomic.wait atomic.notify Thread Data1 Data1 Data1

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

https://github.com/ragingwind/wasm-hello-world/tree/master/clang-thread Threads in C

Slide 57

Slide 57 text

https://github.com/ragingwind/wasm-hello-world/tree/master/rust-thread worker.js lib.rs Threads in Rust

Slide 58

Slide 58 text

https://github.com/ragingwind/wasm-hello-world/tree/master/rust-thread Threads in Rust

Slide 59

Slide 59 text

https://medium.com/google-earth/performance-of-web-assembly-a-thread-on-threading-54f62fd50cf7

Slide 60

Slide 60 text

https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 61

Slide 61 text

https://rustwasm.github.io/wasm-bindgen/exbuild/raytra

Slide 62

Slide 62 text

https://code.videolan.org/jbk/vlc.js vlc.js

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

Single Instruction, Multiple Data

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

https://github.com/google/mediapipe

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

https://dannadori.medium.com/google-meet-virtual-background-with-amazon-chime-sdk-34656a625fed

Slide 71

Slide 71 text

https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 72

Slide 72 text

https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 73

Slide 73 text

https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 74

Slide 74 text

https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 75

Slide 75 text

https://www.youtube.com/watch?v=kZrl91SPSpc

Slide 76

Slide 76 text

Non-Web - WebAssembly System Interface (WASI) - WebAssembly Interface Types

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ WebAssembly System Interface (WASI)

Slide 79

Slide 79 text

https://hacks.mozilla.org/2019/08/webassembly-interface-types/ WebAssembly Interface Type

Slide 80

Slide 80 text

WASI Software Architecture https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-overview.md

Slide 81

Slide 81 text

Practice - Hello Wasm - WASI Demo

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

˞ ˝ ˟

Slide 87

Slide 87 text

https://github.com/bytecodealliance/wasmtime/blob/main/docs/wasm-rust.md ˝ ˞ ˟ ˠ

Slide 88

Slide 88 text

https://github.com/bytecodealliance/wasmtime/blob/main/docs/wasm-rust.md ˝ ˞ ˟ ˠ

Slide 89

Slide 89 text

https://github.com/bytecodealliance/wasmtime/blob/main/docs/wasm-rust.md WARN

Slide 90

Slide 90 text

No content

Slide 91

Slide 91 text

https://github.com/ragingwind/wasm-helloworld/tree/master/rust-wasi-node

Slide 92

Slide 92 text

WAT Debugging

Slide 93

Slide 93 text

$ rustc -g --target wasm32-unknown-unknown -O ./src/lib.rs -o ./pkg/square.wasm Source map

Slide 94

Slide 94 text

Use case

Slide 95

Slide 95 text

https://webassembly.org/docs/use-cases/

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

https://lichess.org/analysis

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

No content

Slide 102

Slide 102 text

https://www.figma.com/blog/webassembly-cut-figmas-load-time-by-3x/

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

Roadmap - MVP features released in 2017 - Next proposal is ready to go

Slide 111

Slide 111 text

https://webassembly.org/roadmap/

Slide 112

Slide 112 text

Reference

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

https://github.com/WebAssembly/proposals

Slide 115

Slide 115 text

No content