Skip to content

Commit

Permalink
chore: upgrade wasmtime to v.28 (#3330)
Browse files Browse the repository at this point in the history
Wasmtime release notes:
https://github.com/bytecodealliance/wasmtime/releases/tag/v28.0.0

- Changed `LinearMemory` trait API,
[code](bytecodealliance/wasmtime#9577)
- Changed static/dynamic memory config, removed
`static_memory_maximum_size`
[code](bytecodealliance/wasmtime#9545)

---------

Co-authored-by: Andriy Berestovskyy <[email protected]>
Co-authored-by: IDX GitHub Automation <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2025
1 parent ba5e99b commit 8054acf
Show file tree
Hide file tree
Showing 20 changed files with 3,739 additions and 2,715 deletions.
927 changes: 667 additions & 260 deletions Cargo.Bazel.Fuzzing.json.lock

Large diffs are not rendered by default.

224 changes: 144 additions & 80 deletions Cargo.Bazel.Fuzzing.toml.lock

Large diffs are not rendered by default.

909 changes: 658 additions & 251 deletions Cargo.Bazel.json.lock

Large diffs are not rendered by default.

220 changes: 142 additions & 78 deletions Cargo.Bazel.toml.lock

Large diffs are not rendered by default.

189 changes: 119 additions & 70 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions bazel/external_crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
version = "^0.217.0",
),
"wasmtime": crate.spec(
version = "^27.0.0",
version = "^28.0.0",
default_features = False,
features = [
"cranelift",
Expand All @@ -1441,7 +1441,7 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable
],
),
"wasmtime-environ": crate.spec(
version = "^27.0.0",
version = "^28.0.0",
),
"wast": crate.spec(
version = "^212.0.0",
Expand Down
4 changes: 2 additions & 2 deletions rs/embedders/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ slog-term = { workspace = true }
tempfile = { workspace = true }
wasm-encoder = { workspace = true }
wasmparser = { workspace = true }
wasmtime = { version = "27.0.0", default-features = false, features = [
wasmtime = { version = "28.0.0", default-features = false, features = [
'cranelift',
'gc',
'gc-null',
'parallel-compilation',
'runtime',
] }
wasmtime-environ = "27.0.0"
wasmtime-environ = "28.0.0"

# Wasmtime depends on 0.4.2 but specifies 0.4.1 in the toml file.
# Enforce 0.4.2 using a dummy dependency until the upstream issue
Expand Down
2 changes: 1 addition & 1 deletion rs/embedders/src/wasm_utils/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ pub fn wasmtime_validation_config(embedders_config: &EmbeddersConfig) -> wasmtim
// expect to see then the changes will likely need to be coordinated
// with a change in how we create the memories in the implementation
// of `wasmtime::MemoryCreator`.
.static_memory_maximum_size(MAX_STABLE_MEMORY_IN_BYTES)
.memory_reservation(MAX_STABLE_MEMORY_IN_BYTES)
.guard_before_linear_memory(true)
.memory_guard_size(MIN_GUARD_REGION_SIZE as u64)
.max_wasm_stack(MAX_WASM_STACK_SIZE);
Expand Down
13 changes: 2 additions & 11 deletions rs/embedders/src/wasmtime_embedder/host_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ impl MmapMemory {
fn as_ptr(&self) -> *mut c_void {
self.wasm_memory
}

fn wasm_accessible(&self) -> std::ops::Range<usize> {
let start = self.wasm_memory as usize;
start..start + self.size_in_bytes
}
}

impl Drop for MmapMemory {
Expand Down Expand Up @@ -231,8 +226,8 @@ unsafe impl LinearMemory for WasmtimeMemory {
convert_pages_to_bytes(self.used.load(Ordering::SeqCst))
}

fn maximum_byte_size(&self) -> Option<usize> {
Some(convert_pages_to_bytes(self.max_size_in_pages))
fn byte_capacity(&self) -> usize {
convert_pages_to_bytes(self.max_size_in_pages)
}

fn grow_to(&mut self, new_size: usize) -> anyhow::Result<()> {
Expand Down Expand Up @@ -264,8 +259,4 @@ unsafe impl LinearMemory for WasmtimeMemory {
fn as_ptr(&self) -> *mut u8 {
self.mem.as_ptr() as *mut _
}

fn wasm_accessible(&self) -> std::ops::Range<usize> {
self.mem.wasm_accessible()
}
}
46 changes: 46 additions & 0 deletions rs/execution_environment/benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Execution Benchmarks
====================

Quick Start
-----------

1. To run all benchmarks and compare them to the committed baseline:

```sh
./rs/execution_environment/benches/run-all-benchmarks.sh | tee summary.txt
```

The summary will be generated in the `summary.txt` file.

2. To update the baseline:

```sh
cp *.min rs/execution_environment/benches/baseline
git add rs/execution_environment/benches/baseline/*
git commit -m "Update benches baseline"
```

Adding a New Benchmark
----------------------

1. Create a new benchmark and test it with `bazel run ...`.

2. To integrate the new benchmark into the CI pipeline:

```Starlark
rust_ic_bench(
name = "my_new_bench",
with_test = True,
[...]
)
```

Note, a single benchmark iteration should run in a reasonable amount of time:

```sh
bazel run //rs/execution_environment:my_new_bench -- --test
```

3. To include the new benchmark in the comparison:

Edit script: `rs/execution_environment/benches/run-all-benchmarks.sh`
30 changes: 15 additions & 15 deletions rs/execution_environment/benches/baseline/EMBEDDERS_COMPILATION.min
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
test compilation/simple ... bench: 856325 ns/iter (+/- 25738)
test compilation/empty ... bench: 630420 ns/iter (+/- 41102)
test compilation/many_adds ... bench: 227841128 ns/iter (+/- 8410338)
test compilation/many_funcs ... bench: 647063352 ns/iter (+/- 21812709)
test compilation/real_world_wasm ... bench: 763950795 ns/iter (+/- 14152869)
test deserialization/simple ... bench: 38591 ns/iter (+/- 2403)
test deserialization/empty ... bench: 36263 ns/iter (+/- 2421)
test deserialization/many_adds ... bench: 367652 ns/iter (+/- 18746)
test deserialization/many_funcs ... bench: 9611403 ns/iter (+/- 132725)
test deserialization/real_world_wasm ... bench: 9634751 ns/iter (+/- 116462)
test validation-instrumentation/simple ... bench: 44939 ns/iter (+/- 199)
test validation-instrumentation/empty ... bench: 12826 ns/iter (+/- 20)
test validation-instrumentation/many_adds ... bench: 17189632 ns/iter (+/- 118273)
test validation-instrumentation/many_funcs ... bench: 130757108 ns/iter (+/- 2148530)
test validation-instrumentation/real_world_wasm ... bench: 249637146 ns/iter (+/- 1794580)
test compilation/simple ... bench: 829698 ns/iter (+/- 28216)
test compilation/empty ... bench: 620128 ns/iter (+/- 34488)
test compilation/many_adds ... bench: 212131971 ns/iter (+/- 12029294)
test compilation/many_funcs ... bench: 637222024 ns/iter (+/- 24032914)
test compilation/real_world_wasm ... bench: 777318340 ns/iter (+/- 17189505)
test deserialization/simple ... bench: 34086 ns/iter (+/- 3837)
test deserialization/empty ... bench: 32830 ns/iter (+/- 3067)
test deserialization/many_adds ... bench: 270273 ns/iter (+/- 3299)
test deserialization/many_funcs ... bench: 9520767 ns/iter (+/- 160008)
test deserialization/real_world_wasm ... bench: 9187724 ns/iter (+/- 588787)
test validation-instrumentation/simple ... bench: 45814 ns/iter (+/- 185)
test validation-instrumentation/empty ... bench: 13064 ns/iter (+/- 39)
test validation-instrumentation/many_adds ... bench: 17172563 ns/iter (+/- 203235)
test validation-instrumentation/many_funcs ... bench: 113483470 ns/iter (+/- 4219009)
test validation-instrumentation/real_world_wasm ... bench: 266833186 ns/iter (+/- 9943536)
Loading

0 comments on commit 8054acf

Please sign in to comment.