Slide 1

Slide 1 text

RubyWorld Conference 2022 Ruby & WebAssembly Introduction Yuta Saito (@kateinoigakukun)

Slide 2

Slide 2 text

About me • Yuta Saito / @kateinoigakukun • ૣҴాେֶ جװཧ޻ֶ෦ ৘ใཧ޻ֶՊ4೥ • ύʔτλΠϜ։ൃऀ @ • CRubyͷWebAssembly/WASIϝϯςφ

Slide 3

Slide 3 text

WebAssembly (Wasm) • ϒϥ΢βʹ࣮૷͞Ε͍ͯΔɺϙʔλϒϧͳ࣮ߦόΠφϦܗࣜ • Google Earth, Figma, GoodNotes, etc.. Introduction

Slide 4

Slide 4 text

WebAssembly (Wasm) • CPUΞʔΩςΫνϟʹґଘ͠ͳ͍ • ιʔεݴޠʹґଘ͠ͳ͍ • ϗετ؀ڥ΁ͷΞΫηε੍ݶ • ʢͦͦ͜͜ʣߴ଎ https://hacks.mozilla.org/2017/02/creating-and-working-with-webassembly-modules/ ಛ௃

Slide 5

Slide 5 text

WebAssembly (Wasm) • σβΠϯॳظ͔Βϒϥ΢βҎ֎ͷ؀ڥʹ΋ϥϯλΠϜΛຒΊࠐΉ͜ͱΛ૝ఆ Webϒϥ΢βҎ֎Ͱ΋ศར https://github.com/WebAssembly/design/commit/070f56c5c59030e2d735973f3e10dbe2c87366db

Slide 6

Slide 6 text

WebAssembly (Wasm) • ϒϥ΢β͔Βಠཱͨ͠WebAssemblyϥϯλΠϜ࣮૷͕ଟ਺ • Wasmtime, WAMR, Wasmer, etc… • ΞϓϦέʔγϣϯʹ૊ΈࠐΈ΍͍͢ (like mruby) • ϢʔβʹΑΔʮ৴པͰ͖ͳ͍ϓϩάϥϜʯΛೖྗ͢Διϑτ΢ΣΞͰศར • ྫ) ϓϥάΠϯγεςϜɺαʔόʔϨεɺetc… Webϒϥ΢βҎ֎Ͱ΋ศར

Slide 7

Slide 7 text

WebAssembly (Wasm) • ݴޠଆ • WasmʹίϯύΠϧͰ͖Ε͹ɺ༷ʑͳ؀ڥͰಈ͔ͤΔ • ϓϥοτϑΥʔϜଆ • WasmϥϯλΠϜ͑͋͞Ε͹ɺ༷ʑͳݴޠΛαϙʔτ͢Δ͜ͱ͕Ͱ͖Δ ݴޠ΋ϓϥοτϑΥʔϜ΋خ͍͠ ϓϩάϥϜަ׵ܗࣜʹͽͬͨΓ

Slide 8

Slide 8 text

ϓϩάϥϜͷ഑෍୯Ґ Computer Hypervisor OS OS OS OS Libs Libs Libs App App App Computer OS Docker Libs Libs Libs App App App Computer OS WebAssembly Runtime App App App VMΠϝʔδ ίϯςφ .wasm

Slide 9

Slide 9 text

Ruby on WebAssembly • RubyΠϯλϓϦλ (CRuby) ΛWebAssemblyʹίϯύΠϧ • ωΠςΟϒͱ΄΅ಉ͡ػೳΛఏڙ • Ruby͕ϒϥ΢β/༷ʑͳWasm؀ڥͰಈ͘Α͏ʹʂ • Ͳ͜Ͱ΋Ruby

Slide 10

Slide 10 text

͜Ε·ͰͷCRubyΛWebAssemblyͰಈ͔͢औΓ૊Έ emrubyʢ͍ʔ͑ΉΔͼʔʣ • EmscriptenπʔϧνΣΠϯͰίϯύΠϧ͞ΕͨCRuby • ϒϥ΢βͰͷར༻͕લఏ Emscripten ϒϥ΢β֎Ͱಈ͔ͤͳ͍ WASI ඪ४Խ͞Ε͓ͯΓɺ
 ϒϥ΢β֎Ͱ΋αϙʔτ͞ΕͯΔ

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

Ruby on WebAssembly puts "Hello, world!"

Slide 13

Slide 13 text

https://kateinoigakukun.github.io/jupyterlite-ruby-kernel

Slide 14

Slide 14 text

https://kateinoigakukun.github.io/jupyterlite-ruby-kernel

Slide 15

Slide 15 text

՝୊ ίʔυαΠζ • RubyεΫϦϓτͷαΠζ: 22MB • ؆୯ͳMini fi cation -> 18MB • RubyΠϯλϓϦλͷαΠζ: 8.2MB • Asyncifyલ: 5.9MB

Slide 16

Slide 16 text

՝୊ ىಈ࣌ؒ • RubyεΫϦϓτͷ࣮ߦ·Ͱʹ60ms • ࢀߟɿJSΤϯδϯʢSpiderMonkeyʣ͸6ms https://bytecodealliance.org/articles/wasmtime-10-performance

Slide 17

Slide 17 text

·ͱΊ • Ruby 3.2Ͱ͸WebAssembly/WASIʹରԠ • ʮͲ͜Ͱ΋Rubyʯ΁ͷ1εςοϓ