Optimize the WASI random_get implementation. (#4917)

* Optimize the WASI `random_get` implementation.

Use `StdRng` instead of the `OsRng` in the default implementation of
`random_get`. This uses a userspace CSPRNG, making `random_get` 3x faster
in simple benchmarks.

* Update cargo-vet audits for cap-std 0.25.3.

* Update all cap-std packages to 0.25.3.
This commit is contained in:
Dan Gohman
2022-09-16 08:27:06 -07:00
committed by GitHub
parent 27435ae398
commit cbd2efd236
10 changed files with 50 additions and 43 deletions

View File

@@ -25,7 +25,7 @@ wasmtime-wasi = { path = "../wasi" }
wasmtime-wasi-crypto = { path = "../wasi-crypto", optional = true }
wasmtime-wasi-nn = { path = "../wasi-nn", optional = true }
wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" }
cap-std = "0.25.0"
cap-std = "0.25.3"
[dev-dependencies]
wat = "1.0.45"

View File

@@ -29,7 +29,7 @@ wat = { version = "1.0.47", optional = true }
# Optional dependencies for the `wasi` feature
wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync", optional = true }
wasmtime-wasi = { path = "../wasi", optional = true }
cap-std = { version = "0.25.0", optional = true }
cap-std = { version = "0.25.3", optional = true }
[features]
default = ['jitdump', 'wat', 'wasi', 'cache', 'parallel-compilation', 'memory-init-cow']

View File

@@ -21,7 +21,7 @@ tempfile = "3.1.0"
os_pipe = "0.9"
anyhow = "1.0.19"
wat = "1.0.47"
cap-std = "0.25.0"
cap-std = "0.25.3"
tokio = { version = "1.8.0", features = ["rt-multi-thread"] }
[features]

View File

@@ -22,8 +22,8 @@ anyhow = "1.0"
thiserror = "1.0"
wiggle = { path = "../wiggle", default-features = false, version = "=2.0.0" }
tracing = "0.1.19"
cap-std = "0.25.0"
cap-rand = "0.25.0"
cap-std = "0.25.3"
cap-rand = "0.25.3"
bitflags = "1.2"
[target.'cfg(unix)'.dependencies]

View File

@@ -15,10 +15,10 @@ include = ["src/**/*", "README.md", "LICENSE" ]
wasi-common = { path = "../", version = "=2.0.0" }
async-trait = "0.1"
anyhow = "1.0"
cap-std = "0.25.0"
cap-fs-ext = "0.25.0"
cap-time-ext = "0.25.0"
cap-rand = "0.25.0"
cap-std = "0.25.3"
cap-fs-ext = "0.25.3"
cap-time-ext = "0.25.3"
cap-rand = "0.25.3"
fs-set-times = "0.17.0"
system-interface = { version = "0.22.0", features = ["cap_std_impls"] }
tracing = "0.1.19"

View File

@@ -141,5 +141,5 @@ impl WasiCtxBuilder {
}
pub fn random_ctx() -> Box<dyn RngCore + Send + Sync> {
Box::new(cap_rand::rngs::OsRng::default(ambient_authority()))
Box::new(cap_rand::std_rng_from_entropy(cap_rand::ambient_authority()))
}

View File

@@ -15,7 +15,7 @@ wasi-common = { path = "../", version = "=2.0.0" }
wasi-cap-std-sync = { path = "../cap-std-sync", version = "=2.0.0" }
wiggle = { path = "../../wiggle", version = "=2.0.0" }
tokio = { version = "1.8.0", features = [ "rt", "fs", "time", "io-util", "net", "io-std", "rt-multi-thread"] }
cap-std = "0.25.0"
cap-std = "0.25.3"
anyhow = "1"
io-lifetimes = { version = "0.7.0", default-features = false }
@@ -29,4 +29,4 @@ io-extras = "0.15.0"
tempfile = "3.1.0"
tokio = { version = "1.8.0", features = [ "macros" ] }
anyhow = "1"
cap-tempfile = "0.25.0"
cap-tempfile = "0.25.3"