Skip to content

Commit

Permalink
Rename stuff from wasmer to wasmtime
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Nov 6, 2023
1 parent 678d67c commit e8d5179
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 36 deletions.
6 changes: 0 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ uuid = { version = "1.2.1", features = ["v4"] }
walkdir = "2.2.5"
wasmbin = "0.6"

# wasmer prior to 4.1.1 had a signal handling bug on macOS.
wasmer = "4.1.1"
wasmer-middlewares = "4.1.1"
wasmer-types = "4.1.1"
wasmer-vm = "4.1.1"

wasmtime = { version = "14", default-features = false, features = ["cranelift"] }

# We use the "ondemand" feature to allow connecting after the start,
Expand Down
4 changes: 2 additions & 2 deletions crates/cli/src/subcommands/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub fn cli() -> clap::Command {
Arg::new("host_type")
.long("host-type")
.short('t')
.value_parser(["wasmer"])
.default_value("wasmer")
.value_parser(["wasmtime"])
.default_value("wasmtime")
.help("The type of host that should be for hosting this module"),
)
.arg(
Expand Down
6 changes: 2 additions & 4 deletions crates/client-api/src/routes/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use spacetimedb::host::ReducerOutcome;
use spacetimedb::host::UpdateDatabaseSuccess;
use spacetimedb::identity::Identity;
use spacetimedb::json::client_api::StmtResultJson;
use spacetimedb::messages::control_db::{Database, DatabaseInstance, HostType};
use spacetimedb::messages::control_db::{Database, DatabaseInstance};
use spacetimedb::sql::execute::execute;
use spacetimedb_lib::address::AddressForUrl;
use spacetimedb_lib::identity::AuthCtx;
Expand Down Expand Up @@ -386,9 +386,7 @@ pub async fn info<S: ControlStateDelegate>(
.ok_or((StatusCode::NOT_FOUND, "No such database."))?;
log::trace!("Fetched database from the worker db for address: {address:?}");

let host_type = match database.host_type {
HostType::Wasmer => "wasmer",
};
let host_type: &str = database.host_type.as_ref();
let response_json = json!({
"address": database.address,
"identity": database.identity,
Expand Down
4 changes: 0 additions & 4 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ tracing.workspace = true
url.workspace = true
urlencoding.workspace = true
uuid.workspace = true
# wasmer-middlewares.workspace = true
# wasmer-types.workspace = true
# wasmer-vm.workspace = true
# wasmer.workspace = true
wasmtime.workspace = true
# Rocksdb ostorage backend, linked only if "rocksdb" feature enabled.
rocksdb = {workspace = true, optional = true}
Expand Down
9 changes: 4 additions & 5 deletions crates/core/src/host/host_controller.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::hash::hash_bytes;
use crate::host::wasmer;
use crate::host;
use crate::messages::control_db::HostType;
use crate::module_host_context::ModuleHostContext;
use anyhow::Context;
// use parking_lot::{Condvar, Mutex};
use parking_lot::Mutex;
use serde::Serialize;
use std::collections::HashMap;
Expand Down Expand Up @@ -266,13 +265,13 @@ impl HostController {
let module_hash = hash_bytes(&mhc.program_bytes);
let (threadpool, energy_monitor) = (self.threadpool.clone(), self.energy_monitor.clone());
let module_host = match mhc.host_type {
HostType::Wasmer => {
HostType::Wasmtime => {
// make_actor with block_in_place since it's going to take some time to compute.
let start = Instant::now();
let actor = tokio::task::block_in_place(|| {
wasmer::make_actor(mhc.dbic, module_hash, &mhc.program_bytes, mhc.scheduler, energy_monitor)
host::wasmtime::make_actor(mhc.dbic, module_hash, &mhc.program_bytes, mhc.scheduler, energy_monitor)
})?;
log::trace!("wasmer::make_actor blocked for {:?}", start.elapsed());
log::trace!("wasmtime::make_actor blocked for {:?}", start.elapsed());
ModuleHost::new(threadpool, actor)
}
};
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/host/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod host_controller;
pub(crate) mod module_host;
pub use module_host::{UpdateDatabaseResult, UpdateDatabaseSuccess};
pub mod scheduler;
mod wasmer;
mod wasmtime;

// Visible for integration testing.
pub mod instance_env;
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/host/wasm_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub trait ResourceIndex {

macro_rules! decl_index {
($name:ident => $resource:ty) => {
#[derive(Copy, Clone)] // , wasmer::ValueType
#[derive(Copy, Clone)]
#[repr(transparent)]
pub(super) struct $name(pub u32);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::error::NodesError;
use crate::hash::Hash;

mod wasm_instance_env;
mod wasmer_module;
mod wasmtime_module;

use wasmer_module::WasmerModule;
use wasmtime_module::WasmtimeModule;

use self::wasm_instance_env::WasmInstanceEnv;

Expand All @@ -32,7 +32,7 @@ static ENGINE: Lazy<Engine> = Lazy::new(|| {

static LINKER: Lazy<Linker<WasmInstanceEnv>> = Lazy::new(|| {
let mut linker = Linker::new(&ENGINE);
WasmerModule::link_imports(&mut linker).unwrap();
WasmtimeModule::link_imports(&mut linker).unwrap();
linker
});

Expand All @@ -51,14 +51,14 @@ pub fn make_actor(
let abi = abi::determine_spacetime_abi(func_imports, |imp| imp.module())?;

if let Some(abi) = abi {
abi::verify_supported(WasmerModule::IMPLEMENTED_ABI, abi)?;
abi::verify_supported(WasmtimeModule::IMPLEMENTED_ABI, abi)?;
}

let module = LINKER
.instantiate_pre(&module)
.map_err(InitializationError::Instantiation)?;

let module = WasmerModule::new(module);
let module = WasmtimeModule::new(module);

WasmModuleHostActor::new(dbic, module_hash, module, scheduler, energy_monitor).map_err(Into::into)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ fn log_traceback(func_type: &str, func: &str, e: &wasmtime::Error) {
}

#[derive(Clone)]
pub struct WasmerModule {
pub struct WasmtimeModule {
module: InstancePre<WasmInstanceEnv>,
}

impl WasmerModule {
impl WasmtimeModule {
pub(super) fn new(module: InstancePre<WasmInstanceEnv>) -> Self {
WasmerModule { module }
WasmtimeModule { module }
}

pub const IMPLEMENTED_ABI: abi::VersionTuple = abi::VersionTuple::new(7, 0);

pub(super) fn link_imports(linker: &mut Linker<WasmInstanceEnv>) -> anyhow::Result<()> {
#[allow(clippy::assertions_on_constants)]
const _: () = assert!(WasmerModule::IMPLEMENTED_ABI.major == spacetimedb_lib::MODULE_ABI_MAJOR_VERSION);
const _: () = assert!(WasmtimeModule::IMPLEMENTED_ABI.major == spacetimedb_lib::MODULE_ABI_MAJOR_VERSION);
linker
.func_wrap("spacetime_7.0", "_schedule_reducer", WasmInstanceEnv::schedule_reducer)?
.func_wrap("spacetime_7.0", "_cancel_reducer", WasmInstanceEnv::cancel_reducer)?
Expand Down Expand Up @@ -65,7 +65,7 @@ impl WasmerModule {
}
}

impl module_host_actor::WasmModule for WasmerModule {
impl module_host_actor::WasmModule for WasmtimeModule {
type Instance = WasmerInstance;
type InstancePre = Self;

Expand All @@ -91,7 +91,7 @@ impl module_host_actor::WasmModule for WasmerModule {
}
}

impl module_host_actor::WasmInstancePre for WasmerModule {
impl module_host_actor::WasmInstancePre for WasmtimeModule {
type Instance = WasmerInstance;

fn instantiate(&self, env: InstanceEnv, func_names: &FuncNames) -> Result<Self::Instance, InitializationError> {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/messages/control_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ pub struct NodeStatus {
#[strum(serialize_all = "lowercase")]
#[repr(i32)]
pub enum HostType {
Wasmer = 0,
Wasmtime = 0,
}
2 changes: 1 addition & 1 deletion crates/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl spacetimedb_client_api::ControlStateWriteAccess for StandaloneEnv {
id: 0,
address: spec.address,
identity: *identity,
host_type: HostType::Wasmer,
host_type: HostType::Wasmtime,
num_replicas: spec.num_replicas,
program_bytes_address,
publisher_address,
Expand Down

0 comments on commit e8d5179

Please sign in to comment.