https://github.com/esoterra/wasmio2024
Demo for my Wasm IO 2024 talk!
https://github.com/esoterra/wasmio2024
claw-lang component-model rust wasm
Last synced: 2 months ago
JSON representation
Demo for my Wasm IO 2024 talk!
- Host: GitHub
- URL: https://github.com/esoterra/wasmio2024
- Owner: esoterra
- License: mit
- Created: 2024-03-13T16:51:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T08:55:45.000Z (over 2 years ago)
- Last Synced: 2025-07-02T06:47:28.246Z (12 months ago)
- Topics: claw-lang, component-model, rust, wasm
- Language: Rust
- Homepage: https://esoterra.dev/talks/2024-wasm-io/
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Wasm IO 2024 Claw Demo
## Setup
```sh
cargo install claw-cli
cargo install component-opt
cargo install --git https://github.com/peterhuene/wac --locked
cargo build
```
## CI Jobs
```sh
# Look at `job` world in wit/claw.wit
# Look at src/main.rs
# Test out an empty job
claw-cli compile -i programs/empty-job.claw --wit wit -o empty-job.wasm
cargo run -- -i empty-job.wasm
# Test out a basic job
claw-cli compile -i programs/basic-job.claw --wit wit -o basic-job.wasm
cargo run -- -i basic-job.wasm
# Test out a simple proxy and composition
claw-cli compile -i programs/timer-proxy.claw --wit wit -o timer-proxy.wasm
wac encode -d claw:basic-job=basic-job.wasm -d claw:timer-proxy=timer-proxy.wasm -o job-with-timer.wasm programs/job-with-timer.wac
```
## Component Optimization
```sh
# Print file size (expect 1212 bytes)
ls -l timer-proxy.wasm
# Print optimized file size (expect 1064)
component-opt -i timer-proxy.wasm -o timer-proxy-opt.wasm
ls -l timer-proxy-opt.wasm
# Rerun the demo to check it still works
wac encode -d claw:basic-job=basic-job.wasm -d claw:timer-proxy=timer-proxy-opt.wasm -o job-with-timer-opt.wasm programs/job-with-timer.wac
cargo run -- -i job-with-timer-opt.wasm
```
This is a 15% binary size reduction to barely over 1kb!!