diff --git a/CHANGELOG.md b/CHANGELOG.md index e377c5e9e33..1595746ce7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * [#1881](https://github.com/wasmerio/wasmer/pull/1881) Added `UnsupportedTarget` error to `CompileError` * [#1908](https://github.com/wasmerio/wasmer/pull/1908) Implemented `TryFrom>` for `i32`/`u32`/`i64`/`u64`/`f32`/`f64` * [#1911](https://github.com/wasmerio/wasmer/pull/1911) Generalized signature type in `Function::new` and `Function::new_with_env` to accept owned and reference `FunctionType` as well as array pairs. This allows users to define signatures as constants. Implemented `From<([Type; $N], [Type; $M])>` for `FunctionType` to support this. +* [#1927](https://github.com/wasmerio/wasmer/pull/1927) Added mmap support in `Engine::deserialize_from_file` to speed up artifact loading ### Changed diff --git a/Cargo.lock b/Cargo.lock index e67b235f73f..a383d0cf98f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1186,6 +1186,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "memmap2" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b70ca2a6103ac8b665dc150b142ef0e4e89df640c9e6cf295d189c3caebe5a" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.1" @@ -2465,7 +2474,6 @@ version = "1.0.0-beta1" dependencies = [ "blake3", "hex", - "memmap", "thiserror", "wasmer", ] @@ -2613,6 +2621,7 @@ dependencies = [ "backtrace", "bincode", "lazy_static", + "memmap2", "more-asserts", "rustc-demangle", "serde", diff --git a/lib/cache/Cargo.toml b/lib/cache/Cargo.toml index 865e78500bf..5832d6946a1 100644 --- a/lib/cache/Cargo.toml +++ b/lib/cache/Cargo.toml @@ -12,7 +12,6 @@ edition = "2018" [dependencies] wasmer = { path = "../api", version = "1.0.0-beta1", default-features = false } -memmap = "0.7" hex = "0.4" thiserror = "1" blake3 = "0.3" diff --git a/lib/engine/Cargo.toml b/lib/engine/Cargo.toml index efa4c8f900d..72aa3350f3d 100644 --- a/lib/engine/Cargo.toml +++ b/lib/engine/Cargo.toml @@ -18,6 +18,7 @@ target-lexicon = { version = "0.11", default-features = false } # flexbuffers = { path = "../../../flatbuffers/rust/flexbuffers", version = "0.1.0" } backtrace = "0.3" rustc-demangle = "0.1" +memmap2 = "0.1.0" more-asserts = "0.2" thiserror = "1.0" serde = { version = "1.0", features = ["derive", "rc"] } diff --git a/lib/engine/src/engine.rs b/lib/engine/src/engine.rs index 2828bfc52a3..8cfceb3a83f 100644 --- a/lib/engine/src/engine.rs +++ b/lib/engine/src/engine.rs @@ -2,6 +2,7 @@ use crate::tunables::Tunables; use crate::{Artifact, DeserializeError}; +use memmap2::Mmap; use std::path::Path; use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; use std::sync::Arc; @@ -51,8 +52,9 @@ pub trait Engine { &self, file_ref: &Path, ) -> Result, DeserializeError> { - let bytes = std::fs::read(file_ref)?; - self.deserialize(&bytes) + let file = std::fs::File::open(file_ref)?; + let mmap = Mmap::map(&file)?; + self.deserialize(&mmap) } /// A unique identifier for this object.