Better wasm instance cache (#5109)

* Wasm instance cache

* Reduce slot locking

* Fixed test

* Dispose of instance in case of error

* Fixed benches

* Style, comments, some renames

* Replaced upgradable lock with mutex

* Bump dependencies

* Re-export CallInWasm

* Update client/executor/src/wasm_runtime.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/executor/src/native_executor.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/executor/src/native_executor.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/executor/src/wasm_runtime.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/executor/wasmtime/src/runtime.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/executor/src/wasm_runtime.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/executor/src/wasm_runtime.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update client/executor/src/wasm_runtime.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Indents

* Whitespace

* Formatting

* Added issue link

Co-authored-by: Benjamin Kampmann <ben.kampmann@googlemail.com>
Co-authored-by: Gavin Wood <github@gavwood.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Benjamin Kampmann
2020-03-05 14:02:04 +01:00
committed by GitHub
parent 40b243f1c8
commit d3208aa7bc
19 changed files with 730 additions and 609 deletions
+83 -66
View File
@@ -713,25 +713,23 @@ checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
[[package]]
name = "cranelift-bforest"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd0f53d59dc9ab1c8ab68c991d8406b52b7a0aab0b15b05a3a6895579c4e5dd9"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"cranelift-entity",
]
[[package]]
name = "cranelift-codegen"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0381a794836fb994c47006465d46d46be072483b667f36013d993b9895117fee"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"byteorder 1.3.4",
"cranelift-bforest",
"cranelift-codegen-meta",
"cranelift-codegen-shared",
"cranelift-entity",
"gimli 0.20.0",
"gimli",
"log 0.4.8",
"serde",
"smallvec 1.2.0",
@@ -741,9 +739,8 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "208c3c8d82bfef32a534c5020c6cfc3bc92f41388f1246b7bb98cf543331abaa"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity",
@@ -751,24 +748,21 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea048c456a517e56fd6df8f0e3947922897e6e6f61fbc5eb557a36c7b8ff6394"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
[[package]]
name = "cranelift-entity"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c8c7ed50812194c9e9de1fa39c77b39fc9ab48173d5e7ee88b25b6a8953e9b8"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"serde",
]
[[package]]
name = "cranelift-frontend"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21ceb931d9f919731df1b1ecdc716b5c66384b413a7f95909d1f45441ab9bef5"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"cranelift-codegen",
"log 0.4.8",
@@ -778,9 +772,8 @@ dependencies = [
[[package]]
name = "cranelift-native"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "564ee82268bc25b914fcf331edfc2452f2d9ca34f976b187b4ca668beba250c8"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"cranelift-codegen",
"raw-cpuid",
@@ -789,9 +782,8 @@ dependencies = [
[[package]]
name = "cranelift-wasm"
version = "0.58.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de63e2271b374be5b07f359184e2126a08fb24d24a740cbc178b7e0107ddafa5"
version = "0.59.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"cranelift-codegen",
"cranelift-entity",
@@ -799,7 +791,7 @@ dependencies = [
"log 0.4.8",
"serde",
"thiserror",
"wasmparser 0.48.2",
"wasmparser",
]
[[package]]
@@ -1886,27 +1878,18 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "gimli"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00"
dependencies = [
"arrayvec 0.4.12",
"byteorder 1.3.4",
"fallible-iterator",
"indexmap",
"stable_deref_trait",
]
[[package]]
name = "gimli"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633"
dependencies = [
"arrayvec 0.5.1",
"byteorder 1.3.4",
"fallible-iterator",
"indexmap",
"smallvec 1.2.0",
"stable_deref_trait",
]
[[package]]
@@ -3773,6 +3756,20 @@ dependencies = [
"libc",
]
[[package]]
name = "object"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea44a4fd660ab0f38434934ca0212e90fbeaaee54126ef20a3451c30c95bafae"
dependencies = [
"flate2",
"goblin",
"parity-wasm 0.41.0",
"scroll",
"target-lexicon",
"uuid",
]
[[package]]
name = "ole32-sys"
version = "0.2.0"
@@ -6096,11 +6093,11 @@ dependencies = [
"parity-scale-codec",
"parity-wasm 0.41.0",
"sc-executor-common",
"scoped-tls",
"sp-allocator",
"sp-core",
"sp-runtime-interface",
"sp-wasm-interface",
"wasmi",
"wasmtime",
]
@@ -6601,6 +6598,12 @@ dependencies = [
"zeroize 0.9.3",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "scopeguard"
version = "1.1.0"
@@ -8596,6 +8599,12 @@ dependencies = [
"percent-encoding 2.1.0",
]
[[package]]
name = "uuid"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11"
[[package]]
name = "vcpkg"
version = "0.2.8"
@@ -8831,12 +8840,6 @@ dependencies = [
"parity-wasm 0.41.0",
]
[[package]]
name = "wasmparser"
version = "0.48.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "073da89bf1c84db000dd68ce660c1b4a08e3a2d28fd1e3394ab9e7abdde4a0f8"
[[package]]
name = "wasmparser"
version = "0.51.4"
@@ -8845,9 +8848,8 @@ checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a"
[[package]]
name = "wasmtime"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5614d964c3e7d07a13b59aca66103c52656bd80430f0d86dc7eeb3af4f03d4a2"
version = "0.12.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"anyhow",
"backtrace",
@@ -8857,9 +8859,10 @@ dependencies = [
"region",
"rustc-demangle",
"target-lexicon",
"wasmparser 0.51.4",
"wasmparser",
"wasmtime-environ",
"wasmtime-jit",
"wasmtime-profiling",
"wasmtime-runtime",
"wat",
"winapi 0.3.8",
@@ -8867,25 +8870,23 @@ dependencies = [
[[package]]
name = "wasmtime-debug"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feb5900275b4ef0b621ce725b9d5660b12825d7f7d79b392b97baf089ffab8c0"
version = "0.12.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"anyhow",
"faerie",
"gimli 0.19.0",
"gimli",
"more-asserts",
"target-lexicon",
"thiserror",
"wasmparser 0.51.4",
"wasmparser",
"wasmtime-environ",
]
[[package]]
name = "wasmtime-environ"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f04661851e133fb11691c4a0f92a705766b4bbf7afc06811f949e295cc8414fc"
version = "0.12.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"anyhow",
"base64 0.11.0",
@@ -8905,16 +8906,15 @@ dependencies = [
"sha2",
"thiserror",
"toml",
"wasmparser 0.51.4",
"wasmparser",
"winapi 0.3.8",
"zstd",
]
[[package]]
name = "wasmtime-jit"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d451353764ce55c9bb6a8b260063cfc209b7adadd277a9a872ab4563a69e357c"
version = "0.12.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"anyhow",
"cfg-if",
@@ -8927,29 +8927,46 @@ dependencies = [
"region",
"target-lexicon",
"thiserror",
"wasmparser 0.51.4",
"wasmparser",
"wasmtime-debug",
"wasmtime-environ",
"wasmtime-profiling",
"wasmtime-runtime",
"winapi 0.3.8",
]
[[package]]
name = "wasmtime-profiling"
version = "0.12.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"gimli",
"goblin",
"lazy_static",
"libc",
"object",
"scroll",
"serde",
"target-lexicon",
]
[[package]]
name = "wasmtime-runtime"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dbd4fc114b828cae3e405fed413df4b3814d87a92ea029640cec9ba41f0c162"
version = "0.12.0"
source = "git+https://github.com/paritytech/wasmtime?branch=a-thread-safe-api#851887d84d03543f931f6312448d0dd5d8a9324e"
dependencies = [
"backtrace",
"cc",
"cfg-if",
"indexmap",
"lazy_static",
"libc",
"memoffset",
"more-asserts",
"region",
"thiserror",
"wasmtime-environ",
"wasmtime-profiling",
"winapi 0.3.8",
]