Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GoとWASI~超入門~
Search
sugar-cat
September 04, 2024
330
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GoとWASI~超入門~
sugar-cat
September 04, 2024
More Decks by sugar-cat
See All by sugar-cat
HonoとOpenTelemetryで実現するオブザーバービリティ構築
sugarcat7
0
610
ErrorTrackingとOrchestrion
sugarcat7
0
440
DiscordとCloudflare
sugarcat7
2
1.4k
Cloudflare Workflowsを使いたい倒したい
sugarcat7
8
2.8k
tslogで実現するセキュアなメタデータ管理とロギング
sugarcat7
4
1.7k
最近個人開発が熱い ~モニタリング強化編v0.1.0~
sugarcat7
3
530
Honoで実現するバックエンド開発のイマ
sugarcat7
23
6.5k
最近個人開発が熱い ~多言語対応編~
sugarcat7
2
490
ボイラープレート自動生成ツールを使わなくなった話.pdf
sugarcat7
4
800
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Embracing the Ebb and Flow
colly
88
5.2k
Thoughts on Productivity
jonyablonski
76
5.4k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Statistics for Hackers
jakevdp
799
230k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.9k
Transcript
GoとWASI ~超入門~ 2024/9/4 Go Connect #2 @sugar235711
2 sugar cat(@sugar235711) SWE || SRE パフォーマンスとセキュリティが好き 登壇者紹介
3 Agenda 1. WasmとWASI 2. GoとWASI 3. まとめ
4 スタックベースの仮想マシンのバイナリ命令フォーマット Wasmとは WasmとWASI セキュリティ ・サンドボックス環境と明示的な import ポータビリティ ・複数の言語からコンパイル可能 ・Wasmランタイムがあれば、
CPUやOSに依 存しない
5 Go 1.11以降Wasmへのビルドをサポート GoでWasmを使うには? WasmとWASI
6 ・各言語ごとに Wasmモジュールの実装がされている ・実行方法も異なる GoでWasmを扱う際の課題 WasmとWASI
7 Wasmのモジュールアクセスするための IFを標準化するための取り組み Go 1.21からWASIのPreview1がサポート WASIの登場 WasmとWASI
8 ロードマップ WasmとWASI https://bytecodealliance.org/articles/webassembly-the-updated-roadmap-for-developers
9 現在WASI Preview2まで安定版 WASIの仕様 WasmとWASI Preview1 ・主にI/O(POSIX準拠) Preview2 ・コンポーネントモデル (Wasm組み合わせて利用するた
めのABIとWIT) Preview3 ・非同期処理
10 Goは現在Preview2のサポート ...の前段階 ・GOARCH=wasm32への対応 → 未 ・go:wasmexport directive → 済
GoのWASI Preview2対応状況 GoとWASI
11 ・現状、多くのWasm環境では32bitのアドレス空間に 制限有(e.g. Fastly) ・GoのWasmは64bit前提のため、unsafe.Pointerを 使用してポインタのキャストが必要 →GCが誤ってメモリを解放してしまう可能性がある GOARCH=wasm32対応 GoとWASI
12 ABIでuintを32bitで扱うための変換をしている Fastly Compute SDK GoとWASI https://github.com/fastly/compute-sdk-go/blob/c3a63de93dcb2cf090f431846d601c1302886c3e/intern al/abi/prim/prim.go#L28-L34
13 Go 1.23で追加された HostLayoutによってGoのコンパイラがわでよしなに メモリ管理してくれるようになった。 Wasm32/Wasm64を利用者側は意識 せずに済みようになるかも? HostLayout GoとWASI
14 基本はWasm利用者側でスレッドの生成を行う責務がある (ブラウザで並行処理をやる場合は Web Workerなどを組み合わせて実装 を行う必要がある ) コラム: Goroutineによる並行処理はどうなる? GoとWASI
https://github.com/WebAssembly/threads/blob/main/proposals/threads/Overview.md
15 先行してWASI Preview2をサポートされている コラム: TinyGoは? GoとWASI
16 ・WASIはWASMを統一的に扱いやすくするためのインターフェース ・WASIはPreview2まで安定版として仕様が決まっている ・Goの公式のWASIサポートは現状 Preview1 ・TinyGoは先行して Preview2までサポートされている まとめ