Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
213f599
Update wasmtime in Substrate
ark0f Sep 21, 2025
4c56ed6
Update wasmtime
ark0f Sep 21, 2025
39ef448
Initial migration to wasmtime
ark0f Sep 21, 2025
0833ef2
Enable winch
ark0f Sep 21, 2025
efd836b
Enable caching for embedded executor
ark0f Sep 21, 2025
ee40caf
Refactor linker to use MODULE_ENV constant for memory definition
ark0f Sep 21, 2025
cf6ead1
Format WASM memory changed message
ark0f Sep 21, 2025
10d2405
Disable mach ports in Wasmtime
ark0f Sep 22, 2025
9d2cc06
Fix clippy warnings
ark0f Sep 22, 2025
5229aaf
Fix deps
ark0f Sep 22, 2025
dc82dac
Fix deps
ark0f Sep 22, 2025
78b7290
Merge branch 'master' into al/wasmtime-migration
ark0f Sep 22, 2025
9cb0079
Fix clippy on Windows
ark0f Sep 22, 2025
c32ff28
Enable caching in the host executor
ark0f Sep 22, 2025
52e9086
Remove Rust version checks
ark0f Sep 22, 2025
b8ff5e8
Improve error handling in `parse_wat` and update `.rodata` naming
ark0f Sep 22, 2025
c62f715
Enable Windows testing
ark0f Sep 22, 2025
8208bda
Use Wasmtime caching in embedded executor
ark0f Sep 23, 2025
1297806
Enable caching in authorship tests
ark0f Sep 23, 2025
76f08bc
Enable caching in lazy-pages-fuzzer
ark0f Sep 23, 2025
1c67bc3
Merge branch 'master' into al/wasmtime-migration
ark0f May 14, 2026
bbcd064
make workspace-hack
ark0f May 14, 2026
d660c85
Fix sp-application-crypto branch
ark0f May 14, 2026
0ef0d66
wasmtime 44.0.1
ark0f May 14, 2026
ef4395e
Merge remote-tracking branch 'origin/master' into al/wasmtime-migration
ark0f May 14, 2026
68ea30e
Fixes after merge
ark0f May 14, 2026
63479a5
Remove unused deps
ark0f May 14, 2026
d97866f
Merge remote-tracking branch 'origin/master' into al/wasmtime-migration
ark0f May 14, 2026
20eca80
Fix wat dep removed from calc-stack-height
ark0f May 14, 2026
bafcffa
Fix wat dep removed from calc-stack-height
ark0f May 14, 2026
d936166
Add gear-workspace-hack to sandbox dependencies
ark0f May 14, 2026
b99da05
Fix embedded executor
ark0f May 14, 2026
94a9a9f
Merge remote-tracking branch 'origin/master' into al/wasmtime-migration
ark0f May 15, 2026
438a070
Update workspace hack
ark0f May 15, 2026
a0f8a9a
Remove obsolete cargo-shear metadata
ark0f May 15, 2026
de8e7a2
Remove unused gear-wasmtime-cache dependency
ark0f May 15, 2026
033a293
Remove unused pathdiff dependency and cleanup authorship module
ark0f May 15, 2026
3867fea
Remove unused sandbox build script
ark0f May 15, 2026
4ff6164
Clarify comments and signal handling logic in lazy-pages Unix impleme…
ark0f May 15, 2026
d1b32dd
Resolve TODOs
ark0f May 15, 2026
bf565d6
Update mach2
ark0f May 15, 2026
58d15a3
Justify `macos_use_mach_ports` usage
ark0f May 15, 2026
671663f
Update instruction weights estimation
ark0f May 17, 2026
db31a85
refactor(vara): benchmark Wasmtime store growth
ark0f May 17, 2026
6013fd6
Merge remote-tracking branch 'origin/master' into al/verify-wasmtime-…
ark0f May 30, 2026
8d6b65a
chore: fix benchmark license header
ark0f May 30, 2026
5b3829b
test: remove redundant sandbox init test
ark0f May 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ primitive-types = { version = "0.12.2", default-features = false }
proc-macro2 = { version = "1", default-features = false }
prometheus = { version = "0.14.0", default-features = false }
proptest = "1.5.0"
criterion = { version = "0.7", features = ["html_reports"] }
quick-xml = "0.28"
quote = { version = "1.0.36", default-features = false }
rand = { version = "0.8", default-features = false }
Expand Down
7 changes: 7 additions & 0 deletions protocol/sandbox/host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ region.workspace = true

gear-workspace-hack.workspace = true

[dev-dependencies]
criterion.workspace = true

[features]
# See wasmi/extra-checks for more information.
wasmi-extra-checks = ["wasmi/extra-checks"]

[[bench]]
name = "wasmtime_store_growth"
harness = false
157 changes: 157 additions & 0 deletions protocol/sandbox/host/benches/wasmtime_store_growth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
// Copyright (C) Gear Technologies Inc.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

use criterion::{Criterion, criterion_group, criterion_main};
use gear_sandbox_env::{EnvironmentDefinition, Instantiate};
use gear_sandbox_host::{
context::{HostResult, SupervisorContext, SupervisorContextDispatcher, SupervisorFuncIndex},
sandbox::{GuestEnvironment, SandboxBackend, SandboxComponents},
};
use parity_scale_codec::Encode;
use sp_wasm_interface_common::{Pointer, WordSize};
use std::{
hint::black_box,
time::{Duration, Instant},
};

const EMPTY_WASM: &[u8] = b"\0asm\x01\0\0\0";
const MAX_OPERATIONS_PER_STORE: u64 =
(wasmtime::DEFAULT_INSTANCE_LIMIT as u64 + wasmtime::DEFAULT_MEMORY_LIMIT as u64) / 2;
Comment thread
ark0f marked this conversation as resolved.

#[derive(Clone, Copy)]
enum ResetPolicy {
Never,
Every(usize),
}

impl ResetPolicy {
fn as_str(self) -> &'static str {
match self {
Self::Never => "long_lived_store",
Self::Every(_) => "clear_periodically",
}
}
}

struct NoopSupervisor;

impl SupervisorContext for NoopSupervisor {
fn data_ptr(&self) -> *const () {
self as *const _ as *const ()
}

fn read_memory_into(
&self,
_address: Pointer<u8>,
dest: &mut [u8],
) -> std::result::Result<(), String> {
dest.fill(0);
Ok(())
}

fn write_memory(
&mut self,
_address: Pointer<u8>,
_data: &[u8],
) -> std::result::Result<(), String> {
Ok(())
}

fn allocate_memory(&mut self, _size: WordSize) -> std::result::Result<Pointer<u8>, String> {
Ok(Pointer::null())
}

fn deallocate_memory(&mut self, _ptr: Pointer<u8>) -> std::result::Result<(), String> {
Ok(())
}
}

impl SupervisorContextDispatcher for NoopSupervisor {
fn dispatch_thunk_id(&self) -> u32 {
0
}

fn invoke(
&mut self,
_invoke_args_ptr: Pointer<u8>,
_invoke_args_len: WordSize,
_func_idx: SupervisorFuncIndex,
) -> HostResult<i64> {
Ok(0)
}
}

fn bench_wasmtime_store_growth(c: &mut Criterion) {
let mut group = c.benchmark_group("wasmtime_store_growth");

for reset_policy in [ResetPolicy::Never, ResetPolicy::Every(50)] {
group.bench_function(reset_policy.as_str(), |b| {
b.iter_custom(|iters| {
let mut state = BenchState::new();
let mut elapsed = Duration::ZERO;
for i in 0..iters {
if i.is_multiple_of(MAX_OPERATIONS_PER_STORE) {
Comment thread
ark0f marked this conversation as resolved.
state = BenchState::new();
}

let instant = Instant::now();
state.run_iteration(i, reset_policy);
elapsed += instant.elapsed();
}
elapsed
})
});
}

group.finish();
}

struct BenchState {
store: SandboxComponents,
env_def: Vec<u8>,
supervisor: NoopSupervisor,
}

impl BenchState {
fn new() -> Self {
Self {
store: SandboxComponents::new(SandboxBackend::Wasmtime),
env_def: EnvironmentDefinition {
entries: Vec::new(),
}
.encode(),
supervisor: NoopSupervisor,
}
}

fn run_iteration(&mut self, iteration: u64, reset_policy: ResetPolicy) {
let memory_idx = self
.store
.new_memory(1, 1)
.expect("failed to create sandbox memory");
black_box(memory_idx);

let guest_env = GuestEnvironment::decode(&self.store, &self.env_def)
.unwrap_or_else(|_| panic!("failed to decode env"));
let instance = self
.store
.instantiate(
Instantiate::Version1,
EMPTY_WASM,
guest_env,
&mut self.supervisor,
)
.unwrap_or_else(|_| panic!("failed to instantiate empty wasm"));
let instance_idx = instance.register(&mut self.store, self.supervisor.dispatch_thunk_id());
black_box(instance_idx);

if let ResetPolicy::Every(clear_every) = reset_policy
&& iteration.is_multiple_of(clear_every as u64)
{
self.store.clear();
}
Comment thread
ark0f marked this conversation as resolved.
}
}

criterion_group!(benches, bench_wasmtime_store_growth);
criterion_main!(benches);
Loading
Loading