Skip to content

Commit c9ccc9a

Browse files
authored
adopt wit-dylib (#171)
* adopt `wit-dylib` This removes the built-in Wasm code generator in favor of `wit-dylib`, which is designed to be reused by interpreters for various languages. It avoids redundant effort and leaves us with less code to maintain overall. This isn't particularly optimized, yet. Given how `wit-dylib[-ffi]` works, we have to acquire and release the CPython GIL a lot more frequently (e.g. for every parameter and result of every import and export call). I haven't measured the overhead in practice, so I don't know if it's significant; if it is, we can make changes to `wit-dylib` to reduce the overhead. Also, `wit-dylib` currently embeds a data section with a lot of metadata that we don't use, so we could slim that down if needed. Otherwise, this should not affect the developer experience in any noticeable way. Signed-off-by: Joel Dice <[email protected]> * run `cargo fmt` Signed-off-by: Joel Dice <[email protected]> * update README.md files to reference `wasmtime` release that actually exists Signed-off-by: Joel Dice <[email protected]> --------- Signed-off-by: Joel Dice <[email protected]>
1 parent 2efafb6 commit c9ccc9a

File tree

17 files changed

+1561
-4679
lines changed

17 files changed

+1561
-4679
lines changed

Cargo.lock

Lines changed: 64 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ clap = { version = "4.5.20", features = ["derive"] }
1414
tar = "0.4.42"
1515
tempfile = "3.13.0"
1616
zstd = "0.13.2"
17-
componentize-py-shared = { path = "shared" }
18-
wasm-encoder = "0.239.0"
19-
wit-parser = "0.239.0"
20-
wit-component = "0.239.0"
21-
wasmparser = "0.239.0"
17+
# TODO: switch to wasm-tools 1.241.0 when available
18+
wasm-encoder = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "b1d8ff59" }
19+
wit-dylib = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "b1d8ff59" }
20+
wit-parser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "b1d8ff59" }
21+
wit-component = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "b1d8ff59" }
22+
wasmparser = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "b1d8ff59" }
2223
indexmap = "2.6.0"
2324
bincode = "1.3.3"
2425
heck = "0.5.0"
2526
pyo3 = { version = "0.26.0", features = [
2627
"abi3-py39",
2728
"extension-module",
2829
], optional = true }
29-
wasmtime = "37.0.2"
30+
wasmtime = { version = "37.0.2", features = [ "component-model-async" ] }
3031
wasmtime-wasi = "37.0.2"
3132
once_cell = "1.20.2"
32-
component-init-transform = { version = "0.2", git = "https://github.com/dicej/component-init", rev = "3800ab6e" }
33+
component-init-transform = { git = "https://github.com/dicej/component-init", rev = "3b9680fe" }
3334
async-trait = "0.1.83"
3435
futures = "0.3.31"
3536
tokio = { version = "1.41.0", features = [
@@ -80,5 +81,4 @@ test-generator = { path = "test-generator" }
8081
flate2 = "1.1.1"
8182

8283
[workspace]
83-
members = ["runtime", "shared", "test-generator"]
84-
84+
members = ["runtime", "test-generator"]

examples/cli/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ run a Python-based component targetting the [wasi-cli] `command` world.
99

1010
## Prerequisites
1111

12-
* `Wasmtime` 37.0.1 or later
12+
* `Wasmtime` 37.0.0 or later
1313
* `componentize-py` 0.18.0
1414

1515
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1616
you don't have `cargo`, you can download and install from
17-
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.1.
17+
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.0.
1818

1919
```
20-
cargo install --version 37.0.1 wasmtime-cli
20+
cargo install --version 37.0.0 wasmtime-cli
2121
pip install componentize-py==0.18.0
2222
```
2323

examples/http/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ run a Python-based component targetting the [wasi-http] `proxy` world.
99

1010
## Prerequisites
1111

12-
* `Wasmtime` 37.0.1 or later
12+
* `Wasmtime` 37.0.0 or later
1313
* `componentize-py` 0.18.0
1414

1515
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1616
you don't have `cargo`, you can download and install from
17-
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.1.
17+
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.0.
1818

1919
```
20-
cargo install --version 37.0.1 wasmtime-cli
20+
cargo install --version 37.0.0 wasmtime-cli
2121
pip install componentize-py==0.18.0
2222
```
2323

examples/matrix-math/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ within a guest component.
1010

1111
## Prerequisites
1212

13-
* `wasmtime` 37.0.1 or later
13+
* `wasmtime` 37.0.0 or later
1414
* `componentize-py` 0.18.0
1515
* `NumPy`, built for WASI
1616

@@ -19,10 +19,10 @@ not yet publish WASI builds.
1919

2020
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
2121
you don't have `cargo`, you can download and install from
22-
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.1.
22+
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.0.
2323

2424
```
25-
cargo install --version 37.0.1 wasmtime-cli
25+
cargo install --version 37.0.0 wasmtime-cli
2626
pip install componentize-py==0.18.0
2727
curl -OL https://github.com/dicej/wasi-wheels/releases/download/v0.0.2/numpy-wasi.tar.gz
2828
tar xf numpy-wasi.tar.gz

examples/sandbox/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ sandboxed Python code snippets from within a Python app.
77

88
## Prerequisites
99

10-
* `wasmtime-py` 37.0.1 or later
10+
* `wasmtime-py` 37.0.0 or later
1111
* `componentize-py` 0.18.0
1212

1313
```
14-
pip install componentize-py==0.18.0 wasmtime==37.0.1
14+
pip install componentize-py==0.18.0 wasmtime==37.0.0
1515
```
1616

1717
## Running the demo

examples/tcp/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ making an outbound TCP request using `wasi-sockets`.
1010

1111
## Prerequisites
1212

13-
* `Wasmtime` 37.0.1 or later
13+
* `Wasmtime` 37.0.0 or later
1414
* `componentize-py` 0.18.0
1515

1616
Below, we use [Rust](https://rustup.rs/)'s `cargo` to install `Wasmtime`. If
1717
you don't have `cargo`, you can download and install from
18-
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.1.
18+
https://github.com/bytecodealliance/wasmtime/releases/tag/v37.0.0.
1919

2020
```
21-
cargo install --version 37.0.1 wasmtime-cli
21+
cargo install --version 37.0.0 wasmtime-cli
2222
pip install componentize-py==0.18.0
2323
```
2424

runtime/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ crate-type = ["staticlib"]
1010
anyhow = "1.0.91"
1111
once_cell = "1.20.2"
1212
pyo3 = { version="0.26.0", features = ["abi3-py312", "num-bigint"] }
13-
componentize-py-shared = { path = "../shared" }
1413
num-bigint = "0.4.6"
1514
wit-bindgen = { version = "0.40.0", default-features = false, features = ["macros", "realloc"] }
1615
wit-bindgen-rt = { version = "0.40.0" }
16+
# TODO: switch to a release when available:
17+
wit-dylib-ffi = { git = "https://github.com/bytecodealliance/wasm-tools", rev = "b1d8ff59", default-features = false }

0 commit comments

Comments
 (0)