Make memfd image creation lazy (on first instantiation).

As a followup to the recent memfd allocator work, this PR makes the
memfd image creation occur on the first instantiation, rather than
immediately when the `Module` is loaded.

This shaves off a potentially surprising cost spike that would have
otherwise occurred: prior to the memfd work, no allocator eagerly read
the module's initial heap state into RAM. The behavior should now more
closely resemble what happened before (and the improvements in overall
instantiation time and performance, as compared to either eager init
with pure-mmap memory or user-mode pagefault handling with uffd,
remain).
This commit is contained in:
Chris Fallin
2022-02-02 15:55:36 -08:00
parent 605c79fd05
commit 2a24a0fbde
4 changed files with 25 additions and 14 deletions

5
Cargo.lock generated
View File

@@ -1890,9 +1890,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.8.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "oorandom"
@@ -3377,6 +3377,7 @@ dependencies = [
"libc",
"log",
"object",
"once_cell",
"paste",
"psm",
"rayon",