diff --git a/.github/workflows/web.yaml b/.github/workflows/web.yaml index fc2f32d9213..3aa2c3c5d94 100644 --- a/.github/workflows/web.yaml +++ b/.github/workflows/web.yaml @@ -1,50 +1,48 @@ # Separate workflow for the wasmer-web crate. # -# Automatically cancel previous workflow runs when a new commit is pushed. -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - name: Wasmer Web + on: push: branches: - main pull_request: + +# Automatically cancel previous workflow runs when a new commit is pushed. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + jobs: web: name: Build and Test (wasmer-web) - strategy: - matrix: - os: [ubuntu-latest] - rust: [nightly-2023-05-25] - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest + defaults: + run: + + working-directory: lib/wasi-web steps: - name: Checkout code uses: actions/checkout@v2 + - name: Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Install Rust - uses: dtolnay/rust-toolchain@master + uses: dtolnay/rust-toolchain@stable with: - toolchain: ${{ matrix.rust }} + toolchain: nightly-2023-05-25 - name: Show Rust version - run: | - rustc --version + run: rustc --version --verbose - name: Check formatting shell: bash - run: | - cd lib/wasi-web - rustup override set nightly-2023-05-25 - rustup component add rustfmt - cargo fmt --check + run: cargo fmt --check - name: Check - continue-on-error: true - env: - CARGO_NET_GIT_FETCH_WITH_CLI: "true" - run: | - cd lib/wasi-web - cargo check + run: cargo check --verbose --locked diff --git a/lib/wasi-web/Cargo.lock b/lib/wasi-web/Cargo.lock index 9528f7acb88..3cc8bf7d49f 100644 --- a/lib/wasi-web/Cargo.lock +++ b/lib/wasi-web/Cargo.lock @@ -30,13 +30,19 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" dependencies = [ "memchr", ] +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -63,9 +69,9 @@ checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e" [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "async-trait" @@ -75,7 +81,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.22", ] [[package]] @@ -122,9 +128,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.0" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "bincode" @@ -141,6 +147,18 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + [[package]] name = "block-buffer" version = "0.9.0" @@ -170,15 +188,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" [[package]] name = "bytecheck" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13fe11640a23eb24562225322cd3e452b93a3d4091d62fab69c70542fcd17d1f" +checksum = "8b6372023ac861f6e6dc89c8344a8f398fb42aaba2b5dbc649ca0c0e9dbcb627" dependencies = [ "bytecheck_derive", "ptr_meta", @@ -187,9 +205,9 @@ dependencies = [ [[package]] name = "bytecheck_derive" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31225543cb46f81a7e224762764f4a6a0f097b1db0b175f69e8065efaa42de5" +checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" dependencies = [ "proc-macro2", "quote", @@ -225,28 +243,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.24" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e3c5919066adf22df73762e50cffcde3a758f2a848b113b586d1f86728b673b" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" dependencies = [ + "android-tzdata", "iana-time-zone", "js-sys", - "num-integer", "num-traits", "wasm-bindgen", "winapi", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -290,9 +298,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" +checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" dependencies = [ "libc", ] @@ -313,55 +321,11 @@ dependencies = [ "typenum", ] -[[package]] -name = "cxx" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.15", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.94" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.15", -] - [[package]] name = "darling" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ "darling_core", "darling_macro", @@ -369,26 +333,26 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.22", ] [[package]] name = "darling_macro" -version = "0.14.4" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn 1.0.109", + "syn 2.0.22", ] [[package]] @@ -398,10 +362,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "907076dfda823b0b36d2a1bb5f90c96660a5bbcd7729e10727f07858f22c4edc" dependencies = [ "cfg-if", - "hashbrown", + "hashbrown 0.12.3", "lock_api", "once_cell", - "parking_lot_core 0.9.7", + "parking_lot_core 0.9.8", ] [[package]] @@ -426,9 +390,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", @@ -488,25 +452,31 @@ dependencies = [ [[package]] name = "enumset" -version = "1.0.12" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" +checksum = "e875f1719c16de097dee81ed675e2d9bb63096823ed3f0ca827b7dea3028bbbb" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.6.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" +checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ "darling", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.22", ] +[[package]] +name = "equivalent" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" + [[package]] name = "errno" version = "0.3.1" @@ -551,13 +521,19 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + [[package]] name = "futures" version = "0.3.28" @@ -614,7 +590,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.22", ] [[package]] @@ -659,9 +635,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "js-sys", @@ -672,9 +648,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "glob" @@ -706,6 +682,12 @@ dependencies = [ "ahash", ] +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heapless" version = "0.7.16" @@ -753,9 +735,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.56" +version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -767,12 +749,11 @@ dependencies = [ [[package]] name = "iana-time-zone-haiku" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ - "cxx", - "cxx-build", + "cc", ] [[package]] @@ -789,9 +770,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -804,10 +785,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", "serde", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + [[package]] name = "instant" version = "0.1.12" @@ -822,9 +813,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi", "libc", @@ -869,18 +860,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.141" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" - -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linked-hash-map" @@ -905,9 +887,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -915,12 +897,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "mach" @@ -988,16 +967,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -1030,18 +999,18 @@ dependencies = [ [[package]] name = "object" -version = "0.30.3" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" @@ -1076,15 +1045,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "smallvec", - "windows-sys 0.45.0", + "windows-targets", ] [[package]] @@ -1095,9 +1064,9 @@ checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "petgraph" @@ -1106,27 +1075,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.3", ] [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.22", ] [[package]] @@ -1189,9 +1158,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" dependencies = [ "unicode-ident", ] @@ -1229,13 +1198,19 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + [[package]] name = "rand" version = "0.8.5" @@ -1297,13 +1272,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.3" +version = "1.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.7.2", ] [[package]] @@ -1312,7 +1287,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", ] [[package]] @@ -1321,6 +1296,12 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" + [[package]] name = "region" version = "3.0.0" @@ -1350,24 +1331,27 @@ checksum = "e3a8614ee435691de62bcffcf4a66d91b3594bf1428a5722e79103249a095690" [[package]] name = "rkyv" -version = "0.7.41" +version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21499ed91807f07ae081880aabb2ccc0235e9d88011867d984525e9a4c3cfa3e" +checksum = "0200c8230b013893c0b2d6213d6ec64ed2b9be2e0e016682b7224ff82cff5c58" dependencies = [ + "bitvec", "bytecheck", - "hashbrown", - "indexmap", + "hashbrown 0.12.3", + "indexmap 1.9.3", "ptr_meta", "rend", "rkyv_derive", "seahash", + "tinyvec", + "uuid", ] [[package]] name = "rkyv_derive" -version = "0.7.41" +version = "0.7.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1c672430eb41556291981f45ca900a0239ad007242d1cb4b4167af842db666" +checksum = "b2e06b915b5c230a17d7a736d1e2e63ee753c256a8614ef3f5147b13a4f5541d" dependencies = [ "proc-macro2", "quote", @@ -1376,9 +1360,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc_version" @@ -1400,9 +1384,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.13" +version = "0.37.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0" +checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" dependencies = [ "bitflags", "errno", @@ -1439,12 +1423,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "scratch" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" - [[package]] name = "seahash" version = "4.1.0" @@ -1474,9 +1452,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" dependencies = [ "serde_derive", ] @@ -1504,20 +1482,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.22", ] [[package]] name = "serde_json" -version = "1.0.96" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" +checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" dependencies = [ "itoa", "ryu", @@ -1530,7 +1508,7 @@ version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" dependencies = [ - "indexmap", + "indexmap 1.9.3", "ryu", "serde", "yaml-rust", @@ -1566,13 +1544,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -1710,32 +1688,39 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" [[package]] name = "tempfile" -version = "3.5.0" +version = "3.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" dependencies = [ + "autocfg", "cfg-if", "fastrand", "redox_syscall 0.3.5", "rustix", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -1748,15 +1733,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - [[package]] name = "termios" version = "0.3.3" @@ -1783,7 +1759,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.22", ] [[package]] @@ -1851,41 +1827,41 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.27.0" +version = "1.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +checksum = "374442f06ee49c3a28a8fc9f01a2596fed7559c6b99b31279c3261778e77d84f" dependencies = [ "autocfg", + "backtrace", "bytes", "pin-project-lite", "tokio-macros", - "windows-sys 0.45.0", ] [[package]] name = "tokio-macros" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a573bdc87985e9d6ddeed1b3d864e8a302c847e40d647746df2f1de209d1ce" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.22", ] [[package]] name = "toml_datetime" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.8" +version = "0.19.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" +checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" dependencies = [ - "indexmap", + "indexmap 2.0.0", "toml_datetime", "winnow", ] @@ -1905,20 +1881,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.22", ] [[package]] name = "tracing-core" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" dependencies = [ "once_cell", "valuable", @@ -1979,9 +1955,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.16" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" dependencies = [ "sharded-slab", "thread_local", @@ -1995,7 +1971,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07" dependencies = [ "tracing", - "tracing-subscriber 0.3.16", + "tracing-subscriber 0.3.17", "wasm-bindgen", ] @@ -2022,9 +1998,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" [[package]] name = "unicode-normalization" @@ -2055,9 +2031,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -2071,6 +2047,12 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" +[[package]] +name = "uuid" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" + [[package]] name = "valuable" version = "0.1.0" @@ -2093,7 +2075,7 @@ dependencies = [ "derivative", "futures", "getrandom", - "indexmap", + "indexmap 1.9.3", "lazy_static", "pin-project-lite", "replace_with", @@ -2355,9 +2337,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.25.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eff853c4f09eec94d76af527eddad4e9de13b11d6286a1ef7134bc30135a2b7" +checksum = "18c41dbd92eaebf3612a39be316540b8377c871cb9bde6b064af962984912881" dependencies = [ "leb128", ] @@ -2369,7 +2351,7 @@ dependencies = [ "bytes", "cfg-if", "derivative", - "indexmap", + "indexmap 1.9.3", "js-sys", "more-asserts", "rustc-demangle", @@ -2426,7 +2408,7 @@ dependencies = [ "bytecheck", "enum-iterator", "enumset", - "indexmap", + "indexmap 1.9.3", "more-asserts", "rkyv", "serde", @@ -2446,7 +2428,7 @@ dependencies = [ "derivative", "enum-iterator", "fnv", - "indexmap", + "indexmap 1.9.3", "lazy_static", "libc", "mach", @@ -2490,7 +2472,7 @@ dependencies = [ "serde_derive", "serde_json", "serde_yaml", - "sha2 0.10.6", + "sha2 0.10.7", "shellexpand", "tempfile", "term_size", @@ -2586,15 +2568,15 @@ version = "0.95.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" dependencies = [ - "indexmap", + "indexmap 1.9.3", "url", ] [[package]] name = "wast" -version = "56.0.0" +version = "60.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b54185c051d7bbe23757d50fe575880a2426a2f06d2e9f6a10fd9a4a42920c0" +checksum = "bd06cc744b536e30387e72a48fdd492105b9c938bb4f415c39c616a7a0a697ad" dependencies = [ "leb128", "memchr", @@ -2604,9 +2586,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.0.62" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56681922808216ab86d96bb750f70d500b5a7800e41564290fd46bb773581299" +checksum = "5abe520f0ab205366e9ac7d3e6b2fc71de44e32a2b58f2ec871b6b575bdcea3b" dependencies = [ "wast", ] @@ -2628,10 +2610,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02ba1b6e7ad252e691a86d727aa422fbc5ed95e9bca4ec8547869e9b5779f8f3" dependencies = [ "anyhow", - "base64 0.21.0", + "base64 0.21.2", "byteorder", "bytes", - "indexmap", + "indexmap 1.9.3", "leb128", "lexical-sort", "once_cell", @@ -2640,7 +2622,7 @@ dependencies = [ "serde", "serde_cbor", "serde_json", - "sha2 0.10.6", + "sha2 0.10.7", "shared-buffer", "thiserror", "url", @@ -2690,7 +2672,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets", ] [[package]] @@ -2706,37 +2688,13 @@ dependencies = [ "windows_x86_64_msvc 0.33.0", ] -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", -] - -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", + "windows-targets", ] [[package]] @@ -2745,21 +2703,15 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_gnullvm", "windows_aarch64_msvc 0.48.0", "windows_i686_gnu 0.48.0", "windows_i686_msvc 0.48.0", "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_gnullvm", "windows_x86_64_msvc 0.48.0", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" @@ -2772,12 +2724,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.0" @@ -2790,12 +2736,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.0" @@ -2808,12 +2748,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.0" @@ -2826,24 +2760,12 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" @@ -2856,12 +2778,6 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.0" @@ -2870,13 +2786,22 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.1" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8970b36c66498d8ff1d66685dc86b91b29db0c7739899012f63a63814b4b28" +checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" dependencies = [ "memchr", ] +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + [[package]] name = "xterm-js-rs" version = "0.1.2" diff --git a/lib/wasi-web/Cargo.toml b/lib/wasi-web/Cargo.toml index a36c7930162..d0401cb98d9 100644 --- a/lib/wasi-web/Cargo.toml +++ b/lib/wasi-web/Cargo.toml @@ -23,8 +23,8 @@ wasm-bindgen = { version = "0.2", features = [ "serde-serialize" ] } wasm-bindgen-futures = "0.4" console_error_panic_hook = "^0.1" js-sys = "0.3" -#tracing = { version = "^0.1", features = [ "log", "release_max_level_info" ] } -tracing = { version = "^0.1", features = [ "log" ] } +tracing = { version = "^0.1", features = [ "log", "release_max_level_info" ] } +#tracing = { version = "^0.1", features = [ "log" ] } tracing-futures = { version = "^0.2" } tracing-subscriber = { version = "^0.2" } tracing-wasm = { version = "^0.2" } diff --git a/lib/wasi-web/app.yaml b/lib/wasi-web/app.yaml new file mode 100644 index 00000000000..03104bbb4fe --- /dev/null +++ b/lib/wasi-web/app.yaml @@ -0,0 +1,4 @@ +--- +kind: wasmer.io/App.v0 +name: wasmer-sh +package: wasmer/wasmer-sh diff --git a/lib/wasi-web/build.sh b/lib/wasi-web/build.sh new file mode 100755 index 00000000000..60f3c557a03 --- /dev/null +++ b/lib/wasi-web/build.sh @@ -0,0 +1,3 @@ +#/bin/bash -e +rm -f dist/* +npm run build diff --git a/lib/wasi-web/cfg/config.toml b/lib/wasi-web/cfg/config.toml new file mode 100644 index 00000000000..f922e474006 --- /dev/null +++ b/lib/wasi-web/cfg/config.toml @@ -0,0 +1,15 @@ +[general] +host = "::" +port = 80 +root = "/public" +log-level = "info" +cache-control-headers = false +compression = true +threads-multiplier = 16 +max-blocking-threads = 32 + +[advanced] + +[[advanced.headers]] +source = "**" +headers = { Access-Control-Allow-Origin = "*", Cross-Origin-Embedder-Policy = "require-corp", Cross-Origin-Opener-Policy = "same-origin", Cache-Control = "max-age=600" } diff --git a/lib/wasi-web/public/core.js b/lib/wasi-web/public/core.js new file mode 100644 index 00000000000..178df2cec1e --- /dev/null +++ b/lib/wasi-web/public/core.js @@ -0,0 +1,83 @@ +import { schedule_wasm_task, register_web_worker, return_web_worker, get_web_worker, claim_web_worker } from '../../..'; + +// WebWorkers are returned to a pool so that they can be reused, this +// is important as the cost of starting another web worker is a very +// costly process as it needs to do a fetch back to the main servers +// to load the main WASM module + +// The purpose of this file is two-fold: +// First: Expose a function to start a web worker. This function must +// not be inlined into the Rust lib, as otherwise bundlers could not +// bundle it -- huh. +export function startWorker(module, memory, state, opts) { + try { + const worker = new Worker(new URL('./worker.js', + import.meta.url), opts); + + // When the worker wants to schedule some work it will + // post a message back to the main thread, otherwise it + // might actually post itself back to the main thread + // when its finished + worker.onmessage = async ev => { + // Web worker has scheduled some work which the main + // thread must orchestrate + let [task, module, memory] = ev.data; + await schedule_wasm_task(task, module, memory); + }; + worker.postMessage([module, memory, state]); + } catch (err) { + return new Promise((res, rej) => { + rej(err); + }); + } + return new Promise((res, rej) => { + res(); + }); +} +export function startWasm(module, memory, ctx, opts, wasm_module, wasm_memory, wasm_cache) { + return new Promise(async (res, rej) => { + try { + // Attempt to get a worker from the pool before we + // create a new web worker as its quite expensive + var worker = null; + var worker_id = claim_web_worker(); + + // If the worker is not available then create a new one + if (worker_id == null) { + worker = new Worker(new URL('./worker.js', + import.meta.url), opts); + + // Register the web worker in the thread pool + worker_id = register_web_worker(worker); + } else { + // If we have claimed a web worker then we need to + // get a reference to it + worker = get_web_worker(worker_id); + } + + // When the worker wants to schedule some work it will + // post a message back to the main thread, otherwise it + // might actually post itself back to the main thread + // when its finished + worker.onmessage = async ev => { + if (ev.data.length == 3) { + // Web worker has scheduled some work which the main + // thread must orchestrate + let [task, module, memory] = ev.data; + await schedule_wasm_task(task, module, memory); + } else { + // Web worker has finished and is now returned to the + // main pool so it can be reused + let [id] = ev.data; + return_web_worker(id); + } + }; + worker.postMessage([worker_id, module, memory, ctx, wasm_module, wasm_memory, wasm_cache]); + } catch (err) { + return new Promise((res, rej) => { + rej(err); + }); + } + res(); + }); +} diff --git a/lib/wasi-web/public/index.html b/lib/wasi-web/public/index.html index 0dab10908a0..a0a9c5f4b2a 100644 --- a/lib/wasi-web/public/index.html +++ b/lib/wasi-web/public/index.html @@ -1,26 +1,30 @@ - - - - - - - - - - - - - - - wasmer.sh - - - - - -
- - + + + + + + + + + + + + + + + wasmer.sh + + + + + + +
+ + + \ No newline at end of file diff --git a/lib/wasi-web/public/worker.js b/lib/wasi-web/public/worker.js index 664696d0fbf..f57ff6051e1 100644 --- a/lib/wasi-web/public/worker.js +++ b/lib/wasi-web/public/worker.js @@ -1,51 +1,3 @@ -import { schedule_wasm_task } from '../../..'; - -// The purpose of this file is two-fold: -// First: Expose a function to start a web worker. This function must -// not be inlined into the Rust lib, as otherwise bundlers could not -// bundle it -- huh. -export function startWorker(module, memory, state, opts, helper) { - try { - const worker = new Worker(new URL('./worker.js', - import.meta.url), opts); - - // When the worker wants to schedule some work it will - // post a message back to the main thread - worker.onmessage = async ev => { - let [task, module, memory] = ev.data; - schedule_wasm_task(task, module, memory); - }; - worker.postMessage([module, memory, state, helper.mainJS()]); - } catch (err) { - return new Promise((res, rej) => { - rej(err); - }); - } - return new Promise((res, rej) => { - res(); - }); -} -export function startWasm(module, memory, ctx, opts, helper, wasm_module, wasm_memory) { - try { - const worker = new Worker(new URL('./worker.js', - import.meta.url), opts); - - // When the worker wants to schedule some work it will - // post a message back to the main thread - worker.onmessage = async ev => { - let [task, module, memory] = ev.data; - schedule_wasm_task(task, module, memory); - }; - worker.postMessage([module, memory, ctx, helper.mainJS(), wasm_module, wasm_memory]); - } catch (err) { - return new Promise((res, rej) => { - rej(err); - }); - } - return new Promise((res, rej) => { - res(); - }); -} export function scheduleTask(task, module, memory) { postMessage([task, module, memory]); } @@ -67,39 +19,35 @@ if (isWorker()) { // When bundling with webpack, this file is relative to the wasm // module file (or package.json) located in `../../..` generated by // wasm-pack. - // When using it without any bundlers, the module that - // provided the `helper` object below is loaded; in other words - // the main wasm module. - if (ev.data.length == 4) { - let [module, memory, state, mainJS] = ev.data; - const importFrom = (typeof __webpack_require__ === 'function') ? import('../../..') : import(mainJS); + if (ev.data.length == 3) { + let [module, memory, state] = ev.data; const { default: init, worker_entry_point, - } = await importFrom; + } = await import('../../..'); await init(module, memory); worker_entry_point(state); } else { + var is_returned = false; try { - // There shouldn't be any additional messages after the first so we - // need to unhook it - self.onmessage = ev => { - console.error("wasm threads can only run a single process then exit", ev); - } - - let [module, memory, ctx, mainJS, wasm_module, wasm_memory] = ev.data; - const importFrom = (typeof __webpack_require__ === 'function') ? import('../../..') : import(mainJS); + let [id, module, memory, ctx, wasm_module, wasm_memory, wasm_cache] = ev.data; const { default: init, wasm_entry_point, - } = await importFrom; + } = await import('../../..'); await init(module, memory); - wasm_entry_point(ctx, wasm_module, wasm_memory); + wasm_entry_point(ctx, wasm_module, wasm_memory, wasm_cache); + + // Return the web worker to the thread pool + postMessage([id]); + is_returned = true; } finally { //Terminate the worker - close(); + if (is_returned == false) { + close(); + } } } } diff --git a/lib/wasi-web/rust-toolchain.toml b/lib/wasi-web/rust-toolchain.toml index 46b3698776c..306f42698a1 100644 --- a/lib/wasi-web/rust-toolchain.toml +++ b/lib/wasi-web/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly" +channel = "nightly-2023-05-25" components = [ "rustfmt", "rust-src", "clippy" ] targets = [ "wasm32-unknown-unknown" ] profile = "minimal" diff --git a/lib/wasi-web/src/glue.rs b/lib/wasi-web/src/glue.rs index e41026cdede..4e413a9690a 100644 --- a/lib/wasi-web/src/glue.rs +++ b/lib/wasi-web/src/glue.rs @@ -38,8 +38,7 @@ pub fn main() { } pub const DEFAULT_BOOT_WEBC: &str = "sharrattj/bash"; -//pub const DEFAULT_BOOT_WEBC: &str = "sharrattj/dash"; -pub const DEFAULT_BOOT_USES: [&str; 2] = ["sharrattj/coreutils", "sharrattj/catsay"]; +pub const DEFAULT_BOOT_USES: [&str; 1] = ["sharrattj/coreutils"]; #[wasm_bindgen] pub fn start() -> Result<(), JsValue> { diff --git a/lib/wasi-web/src/lib.rs b/lib/wasi-web/src/lib.rs index 169c15810e1..15eb0b235ed 100644 --- a/lib/wasi-web/src/lib.rs +++ b/lib/wasi-web/src/lib.rs @@ -1,6 +1,7 @@ mod common; mod glue; mod interval; +mod module_cache; mod pool; mod runtime; diff --git a/lib/wasi-web/src/module_cache.rs b/lib/wasi-web/src/module_cache.rs new file mode 100644 index 00000000000..aaa97e6d177 --- /dev/null +++ b/lib/wasi-web/src/module_cache.rs @@ -0,0 +1,157 @@ +use std::{cell::RefCell, collections::HashMap}; + +use bytes::Bytes; +use wasm_bindgen::{JsCast, JsValue}; +use wasmer::{Engine, Module}; +use wasmer_wasix::runtime::module_cache::{CacheError, ModuleCache, ModuleHash}; + +use crate::pool::{schedule_task, WebRunCommand}; + +std::thread_local! { + static CACHED_MODULES: RefCell> + = RefCell::new(HashMap::new()); +} + +/// A cache that will cache modules in a thread-local variable. +#[derive(Debug, Default)] +#[non_exhaustive] +pub struct WebWorkerModuleCache {} + +impl WebWorkerModuleCache { + fn lookup(&self, key: ModuleHash, deterministic_id: &str) -> Option { + let key = (key, deterministic_id.to_string()); + CACHED_MODULES.with(|m| m.borrow().get(&key).cloned()) + } + + fn insert(&self, key: ModuleHash, module: &Module, deterministic_id: &str) -> bool { + let key = (key, deterministic_id.to_string()); + let old = CACHED_MODULES.with(|m| m.borrow_mut().insert(key, module.clone())); + let already_exists = old.is_some(); + already_exists + } + + fn cache_in_main(&self, key: ModuleHash, module: &Module, deterministic_id: &str) { + let deterministic_id = deterministic_id.to_string(); + let task = Box::new(WebRunCommand::ExecModule { + run: Box::new(move |module| { + let key = (key, deterministic_id); + CACHED_MODULES.with(|m| m.borrow_mut().insert(key, module.clone())); + }), + module_bytes: module.serialize().unwrap(), + }); + let task = Box::into_raw(task); + + let module = JsValue::from(module.clone()) + .dyn_into::() + .unwrap(); + schedule_task(JsValue::from(task as u32), module, JsValue::NULL); + } + + pub fn export() -> JsValue { + CACHED_MODULES.with(|m| { + // Annotation is here to prevent spurious IDE warnings. + #[allow(unused_unsafe)] + unsafe { + let entries = js_sys::Array::new_with_length(m.borrow().len() as u32); + + let mut i = 0; + for ((key, deterministic_id), module) in m.borrow().iter() { + let entry = js_sys::Object::new(); + + js_sys::Reflect::set( + &entry, + &"key".into(), + &JsValue::from(base64::encode(key.as_bytes())), + ) + .unwrap(); + + js_sys::Reflect::set( + &entry, + &"deterministic_id".into(), + &JsValue::from(deterministic_id.clone()), + ) + .unwrap(); + + js_sys::Reflect::set(&entry, &"module".into(), &JsValue::from(module.clone())) + .unwrap(); + + let module_bytes = Box::new(module.serialize().unwrap()); + let module_bytes = Box::into_raw(module_bytes); + js_sys::Reflect::set( + &entry, + &"module_bytes".into(), + &JsValue::from(module_bytes as u32), + ) + .unwrap(); + + entries.set(i, JsValue::from(entry)); + i += 1; + } + + JsValue::from(entries) + } + }) + } + + pub fn import(cache: JsValue) { + CACHED_MODULES.with(|m| { + // Annotation is here to prevent spurious IDE warnings. + #[allow(unused_unsafe)] + unsafe { + let entries = JsValue::from(cache).dyn_into::().unwrap(); + + for i in 0..entries.length() { + let entry = entries.get(i); + + let key = js_sys::Reflect::get(&entry, &"key".into()).unwrap(); + let key = JsValue::as_string(&key).unwrap(); + let key = base64::decode(key).unwrap(); + let key: [u8; 32] = key.try_into().unwrap(); + let key = ModuleHash::from_bytes(key); + + let deterministic_id = + js_sys::Reflect::get(&entry, &"deterministic_id".into()).unwrap(); + let deterministic_id = JsValue::as_string(&deterministic_id).unwrap(); + + let module_bytes = + js_sys::Reflect::get(&entry, &"module_bytes".into()).unwrap(); + let module_bytes: u32 = module_bytes.as_f64().unwrap() as u32; + let module_bytes = module_bytes as *mut Bytes; + let module_bytes = unsafe { Box::from_raw(module_bytes) }; + + let module = js_sys::Reflect::get(&entry, &"module".into()).unwrap(); + let module = module.dyn_into::().unwrap(); + let module: Module = (module, *module_bytes).into(); + + let key = (key, deterministic_id); + m.borrow_mut().insert(key, module.clone()); + } + } + }); + } +} + +#[async_trait::async_trait] +impl ModuleCache for WebWorkerModuleCache { + async fn load(&self, key: ModuleHash, engine: &Engine) -> Result { + self.lookup(key, engine.deterministic_id()) + .ok_or(CacheError::NotFound) + } + + async fn save( + &self, + key: ModuleHash, + engine: &Engine, + module: &Module, + ) -> Result<(), CacheError> { + let already_exists = self.insert(key, module, engine.deterministic_id()); + + // We also send the module to the main thread via a postMessage + // which they relays it to all the web works + if already_exists == false { + self.cache_in_main(key, module, engine.deterministic_id()); + } + + Ok(()) + } +} diff --git a/lib/wasi-web/src/pool.rs b/lib/wasi-web/src/pool.rs index 2cae330e93a..ea41dece7e1 100644 --- a/lib/wasi-web/src/pool.rs +++ b/lib/wasi-web/src/pool.rs @@ -32,7 +32,8 @@ use wasmer_wasix::{ capture_snapshot, runtime::{ task_manager::{ - TaskWasm, TaskWasmRun, TaskWasmRunProperties, WasmResumeTask, WasmResumeTrigger, + TaskExecModule, TaskWasm, TaskWasmRun, TaskWasmRunProperties, WasmResumeTask, + WasmResumeTrigger, }, SpawnMemoryType, }, @@ -45,24 +46,23 @@ use web_sys::{DedicatedWorkerGlobalScope, WorkerOptions, WorkerType}; use xterm_js_rs::Terminal; use super::{common::*, interval::*}; -use crate::runtime::WebTaskManager; +use crate::{module_cache::WebWorkerModuleCache, runtime::WebTaskManager}; pub type BoxRun<'a> = Box; pub type BoxRunAsync<'a, T> = Box Pin + 'static>> + Send + 'a>; -#[derive(Debug, Clone, Copy)] -enum WasmMemoryType { +#[derive(Debug, Clone)] +pub enum WasmMemoryType { CreateMemory, CreateMemoryOfType(MemoryType), - CopyMemory(MemoryType), ShareMemory(MemoryType), } #[derive(Derivative)] #[derivative(Debug)] -struct WasmRunTrigger { +pub struct WasmRunTrigger { #[derivative(Debug = "ignore")] run: Box, memory_ty: MemoryType, @@ -71,16 +71,24 @@ struct WasmRunTrigger { #[derive(Derivative)] #[derivative(Debug)] -struct WasmRunCommand { - #[derivative(Debug = "ignore")] - run: Box, - run_type: WasmMemoryType, - env: WasiEnv, - module_bytes: Bytes, - snapshot: Option, - trigger: Option, - update_layout: bool, - result: Option>, +pub enum WebRunCommand { + ExecModule { + #[derivative(Debug = "ignore")] + run: Box, + module_bytes: Bytes, + }, + SpawnWasm { + #[derivative(Debug = "ignore")] + run: Box, + run_type: WasmMemoryType, + env: WasiEnv, + module_bytes: Bytes, + snapshot: Option, + trigger: Option, + update_layout: bool, + result: Option>, + pool: WebThreadPool, + }, } trait AssertSendSync: Send + Sync {} @@ -165,23 +173,7 @@ pub struct ThreadState { init: Mutex>, } -#[wasm_bindgen] -pub struct LoaderHelper {} -#[wasm_bindgen] -impl LoaderHelper { - #[wasm_bindgen(js_name = mainJS)] - pub fn main_js(&self) -> JsString { - #[wasm_bindgen] - extern "C" { - #[wasm_bindgen(js_namespace = ["import", "meta"], js_name = url)] - static URL: JsString; - } - - URL.clone() - } -} - -#[wasm_bindgen(module = "/public/worker.js")] +#[wasm_bindgen(module = "/public/core.js")] extern "C" { #[wasm_bindgen(js_name = "startWorker")] fn start_worker( @@ -189,7 +181,6 @@ extern "C" { memory: JsValue, shared_data: JsValue, opts: WorkerOptions, - builder: LoaderHelper, ) -> Promise; #[wasm_bindgen(js_name = "startWasm")] @@ -198,13 +189,76 @@ extern "C" { memory: JsValue, ctx: JsValue, opts: WorkerOptions, - builder: LoaderHelper, wasm_module: js_sys::WebAssembly::Module, wasm_memory: JsValue, + wasm_cache: JsValue, ) -> Promise; +} +#[wasm_bindgen(module = "/public/worker.js")] +extern "C" { #[wasm_bindgen(js_name = "scheduleTask")] - fn schedule_task(task: JsValue, module: js_sys::WebAssembly::Module, memory: JsValue); + pub fn schedule_task(task: JsValue, module: js_sys::WebAssembly::Module, memory: JsValue); +} + +fn copy_memory(memory: JsValue, ty: MemoryType) -> Result { + let memory_js = memory + .clone() + .dyn_into::() + .unwrap(); + + let descriptor = js_sys::Object::new(); + + // Annotation is here to prevent spurious IDE warnings. + #[allow(unused_unsafe)] + unsafe { + js_sys::Reflect::set(&descriptor, &"initial".into(), &ty.minimum.0.into()).unwrap(); + if let Some(max) = ty.maximum { + js_sys::Reflect::set(&descriptor, &"maximum".into(), &max.0.into()).unwrap(); + } + js_sys::Reflect::set(&descriptor, &"shared".into(), &ty.shared.into()).unwrap(); + } + + let new_memory = js_sys::WebAssembly::Memory::new(&descriptor).map_err(|_e| { + WasiThreadError::MemoryCreateFailed(wasmer::MemoryError::Generic( + "Error while creating the memory".to_owned(), + )) + })?; + + let src_buffer = memory_js.buffer(); + let src_size: u64 = src_buffer + .unchecked_ref::() + .byte_length() + .into(); + let src_view = js_sys::Uint8Array::new(&src_buffer); + + let pages = ((src_size as usize - 1) / wasmer::WASM_PAGE_SIZE) + 1; + new_memory.grow(pages as u32); + + let dst_buffer = new_memory.buffer(); + let dst_view = js_sys::Uint8Array::new(&dst_buffer); + + #[cfg(feature = "tracing")] + trace!(%src_size, "memory copy started {}"); + + { + let mut offset = 0; + let mut chunk = [0u8; 40960]; + while offset < src_size { + let remaining = src_size - offset; + let sublen = remaining.min(chunk.len() as u64) as usize; + let end = offset.checked_add(sublen.try_into().unwrap()).unwrap(); + src_view + .subarray(offset.try_into().unwrap(), end.try_into().unwrap()) + .copy_to(&mut chunk[..sublen]); + dst_view + .subarray(offset.try_into().unwrap(), end.try_into().unwrap()) + .copy_from(&chunk[..sublen]); + offset += sublen as u64; + } + } + + Ok(new_memory.into()) } impl WebThreadPool { @@ -300,7 +354,15 @@ impl WebThreadPool { SpawnMemoryType::CopyMemory(m, store) => { memory_ty = Some(m.ty(&store)); memory = m.as_jsvalue(&store); - WasmMemoryType::CopyMemory(m.ty(&store)) + + // We copy the memory here rather than later as + // the fork syscalls need to copy the memory + // synchronously before the next thread accesses + // and before the fork parent resumes, otherwise + // there will be memory corruption + memory = copy_memory(memory, m.ty(&store))?; + + WasmMemoryType::ShareMemory(m.ty(&store)) } SpawnMemoryType::ShareMemory(m, store) => { memory_ty = Some(m.ty(&store)); @@ -309,7 +371,7 @@ impl WebThreadPool { } }; - let task = Box::new(WasmRunCommand { + let task = Box::new(WebRunCommand::SpawnWasm { trigger: trigger.map(|trigger| WasmRunTrigger { run: trigger, memory_ty: memory_ty.expect("triggers must have the a known memory type"), @@ -322,6 +384,7 @@ impl WebThreadPool { snapshot, update_layout, result: None, + pool: self.clone(), }); let task = Box::into_raw(task); @@ -358,7 +421,7 @@ fn _build_ctx_and_store( let spawn_type = match run_type { WasmMemoryType::CreateMemory => SpawnMemoryType::CreateMemory, WasmMemoryType::CreateMemoryOfType(mem) => SpawnMemoryType::CreateMemoryOfType(mem), - WasmMemoryType::CopyMemory(ty) | WasmMemoryType::ShareMemory(ty) => { + WasmMemoryType::ShareMemory(ty) => { let memory = match Memory::from_jsvalue(&mut temp_store, &ty, &memory) { Ok(a) => a, Err(_) => { @@ -366,15 +429,7 @@ fn _build_ctx_and_store( return None; } }; - match run_type { - WasmMemoryType::CopyMemory(_) => { - SpawnMemoryType::CopyMemory(memory, temp_store.as_store_ref()) - } - WasmMemoryType::ShareMemory(_) => { - SpawnMemoryType::ShareMemory(memory, temp_store.as_store_ref()) - } - _ => unreachable!(), - } + SpawnMemoryType::ShareMemory(memory, temp_store.as_store_ref()) } }; @@ -462,7 +517,6 @@ impl PoolState { wasm_bindgen::memory(), JsValue::from(ptr as u32), opts, - LoaderHelper {}, )); wasm_bindgen_futures::spawn_local(async move { @@ -643,66 +697,198 @@ pub fn wasm_entry_point( task_ptr: u32, wasm_module: js_sys::WebAssembly::Module, wasm_memory: JsValue, + wasm_cache: JsValue, ) { + // Import the WASM cache + WebWorkerModuleCache::import(wasm_cache); + // Grab the run wrapper that passes us the rust variables (and extract the callback) - let task = task_ptr as *mut WasmRunCommand; + let task = task_ptr as *mut WebRunCommand; let task = unsafe { Box::from_raw(task) }; - let run = (*task).run; - - // Invoke the callback which will run the web assembly module - if let Some((ctx, store)) = _build_ctx_and_store( - wasm_module, - wasm_memory, - task.module_bytes, - task.env, - task.run_type, - task.snapshot, - task.update_layout, - ) { - run(TaskWasmRunProperties { - ctx, - store, - trigger_result: task.result, + match *task { + WebRunCommand::ExecModule { run, module_bytes } => { + let module: Module = (wasm_module, module_bytes).into(); + run(module); + } + WebRunCommand::SpawnWasm { + run, + run_type, + env, + module_bytes, + snapshot, + mut trigger, + update_layout, + mut result, + .. + } => { + // If there is a trigger then run it + let trigger = trigger.take(); + if let Some(trigger) = trigger { + let trigger_run = trigger.run; + let tasks = env.tasks(); + result = Some(tasks.block_on(trigger_run())); + } + + // Invoke the callback which will run the web assembly module + if let Some((ctx, store)) = _build_ctx_and_store( + wasm_module, + wasm_memory, + module_bytes, + env, + run_type, + snapshot, + update_layout, + ) { + run(TaskWasmRunProperties { + ctx, + store, + trigger_result: result, + }); + }; + } + } +} + +struct WebWorker { + worker: JsValue, + available: bool, +} + +std::thread_local! { + static WEB_WORKER_POOL: RefCell> + = RefCell::new(Vec::new()); +} + +#[wasm_bindgen()] +pub fn register_web_worker(web_worker: JsValue) -> u32 { + WEB_WORKER_POOL.with(|u| { + let mut workers = u.borrow_mut(); + workers.push(WebWorker { + worker: web_worker, + available: false, }); - }; + workers.len() - 1 + }) as u32 } #[wasm_bindgen()] -pub fn schedule_wasm_task( +pub fn return_web_worker(id: u32) { + WEB_WORKER_POOL.with(|u| { + let mut workers = u.borrow_mut(); + let worker = workers.get_mut(id as usize); + if let Some(worker) = worker { + worker.available = true; + } + }); +} + +#[wasm_bindgen()] +pub fn get_web_worker(id: u32) -> JsValue { + WEB_WORKER_POOL.with(|u| { + let workers = u.borrow(); + if let Some(worker) = workers.get(id as usize) { + worker.worker.clone() + } else { + JsValue::NULL + } + }) +} + +#[wasm_bindgen()] +pub fn claim_web_worker() -> JsValue { + WEB_WORKER_POOL.with(|u| { + let mut workers = u.borrow_mut(); + for (n, worker) in workers.iter_mut().enumerate() { + if worker.available { + worker.available = false; + return JsValue::from(n); + } + } + JsValue::NULL + }) +} + +#[wasm_bindgen()] +pub async fn schedule_wasm_task( task_ptr: u32, wasm_module: js_sys::WebAssembly::Module, wasm_memory: JsValue, ) { // Grab the run wrapper that passes us the rust variables - let task = task_ptr as *mut WasmRunCommand; - let mut task = unsafe { Box::from_raw(task) }; + let task = task_ptr as *mut WebRunCommand; + let task = unsafe { Box::from_raw(task) }; + match *task { + WebRunCommand::ExecModule { run, module_bytes } => { + let module: Module = (wasm_module, module_bytes).into(); + run(module); + } + WebRunCommand::SpawnWasm { + run, + run_type, + env, + module_bytes, + snapshot, + mut trigger, + update_layout, + mut result, + pool, + } => { + // We will pass it on now + let trigger = trigger.take(); + let trigger_rx = if let Some(trigger) = trigger { + let (tx, rx) = tokio::sync::mpsc::unbounded_channel(); + + // We execute the trigger on another thread as any atomic operations (such as wait) + // are not allowed on the main thread and even through the tokio is asynchronous that + // does not mean it does not have short synchronous blocking events (which it does) + pool.spawn_shared(Box::new(|| { + Box::pin(async move { + let run = trigger.run; + let ret = run().await; + tx.send(ret).ok(); + }) + })); + Some(rx) + } else { + None + }; - // We will pass it on now - let trigger = task.trigger.take(); + // Export the cache + let wasm_cache = WebWorkerModuleCache::export(); - // We will now spawn the process in its own thread - let mut opts = WorkerOptions::new(); - opts.type_(WorkerType::Module); - opts.name(&*format!("Wasm-Thread")); + // We will now spawn the process in its own thread + let mut opts = WorkerOptions::new(); + opts.type_(WorkerType::Module); + opts.name(&*format!("Wasm-Thread")); - wasm_bindgen_futures::spawn_local(async move { - if let Some(trigger) = trigger { - let run = trigger.run; - task.result = Some(run().await); - } + if let Some(mut trigger_rx) = trigger_rx { + result = trigger_rx.recv().await; + } - let task = Box::into_raw(task); - let result = wasm_bindgen_futures::JsFuture::from(start_wasm( - wasm_bindgen::module() - .dyn_into::() - .unwrap(), - wasm_bindgen::memory(), - JsValue::from(task as u32), - opts, - LoaderHelper {}, - wasm_module, - wasm_memory, - )); - _process_worker_result(result, None).await - }); + let task = Box::new(WebRunCommand::SpawnWasm { + run, + run_type, + env, + module_bytes, + snapshot, + trigger: None, + update_layout, + result, + pool, + }); + let task = Box::into_raw(task); + let result = wasm_bindgen_futures::JsFuture::from(start_wasm( + wasm_bindgen::module() + .dyn_into::() + .unwrap(), + wasm_bindgen::memory(), + JsValue::from(task as u32), + opts, + wasm_module, + wasm_memory, + wasm_cache, + )); + _process_worker_result(result, None).await + } + } } diff --git a/lib/wasi-web/src/runtime.rs b/lib/wasi-web/src/runtime.rs index 900ce58ada2..8f76f9deeea 100644 --- a/lib/wasi-web/src/runtime.rs +++ b/lib/wasi-web/src/runtime.rs @@ -21,7 +21,7 @@ use wasmer_wasix::{ http::{DynHttpClient, HttpRequest, HttpResponse}, os::{TtyBridge, TtyOptions}, runtime::{ - module_cache::{FileSystemCache, ModuleCache, ThreadLocalCache}, + module_cache::ModuleCache, package_loader::{BuiltinPackageLoader, PackageLoader}, resolver::{Source, WapmSource}, task_manager::TaskWasm, @@ -37,6 +37,7 @@ use super::webgl::WebGl; #[cfg(feature = "webgl")] use super::webgl::WebGlCommand; use super::{common::*, pool::WebThreadPool}; +use crate::module_cache::WebWorkerModuleCache; #[derive(Debug)] pub(crate) enum TerminalCommandRx { @@ -88,13 +89,8 @@ impl WebRuntime { // even if the filesystem cache fails (i.e. because we're compiled to // wasm32-unknown-unknown and running in a browser), the in-memory layer // should still work. - let package_loader = BuiltinPackageLoader::new_with_client( - BuiltinPackageLoader::default_cache_dir(&wasmer_dir), - http_client.clone(), - ); - let module_cache = ThreadLocalCache::default().with_fallback(FileSystemCache::new( - FileSystemCache::default_cache_dir(&wasmer_dir), - )); + let package_loader = BuiltinPackageLoader::new_only_client(http_client.clone()); + let module_cache = WebWorkerModuleCache::default(); WebRuntime { pool, tasks: runtime, @@ -314,8 +310,8 @@ impl VirtualFile for TermStdout { Ok(()) } - fn unlink(&mut self) -> wasmer_wasix::virtual_fs::Result<()> { - Ok(()) + fn unlink(&mut self) -> BoxFuture<'static, wasmer_wasix::virtual_fs::Result<()>> { + Box::pin(async { Ok(()) }) } fn poll_read_ready( @@ -427,8 +423,8 @@ impl VirtualFile for TermLog { Ok(()) } - fn unlink(&mut self) -> wasmer_wasix::virtual_fs::Result<()> { - Ok(()) + fn unlink(&mut self) -> BoxFuture<'static, wasmer_wasix::virtual_fs::Result<()>> { + Box::pin(async { Ok(()) }) } fn poll_read_ready( diff --git a/lib/wasi-web/wasmer.toml b/lib/wasi-web/wasmer.toml new file mode 100644 index 00000000000..e684ff8a0f6 --- /dev/null +++ b/lib/wasi-web/wasmer.toml @@ -0,0 +1,11 @@ +[package] +name = 'wasmer/wasmer-sh-async' +version = '1.0.3' +description = 'Container that holds the wasmer.sh website.' + +[dependencies] +"wasmer/static-web-server-async" = '1' + +[fs] +public = 'dist' +cfg = 'cfg' diff --git a/lib/wasi-web/webpack.config.mjs b/lib/wasi-web/webpack.config.mjs index 2aaa67cda59..5a661059240 100644 --- a/lib/wasi-web/webpack.config.mjs +++ b/lib/wasi-web/webpack.config.mjs @@ -16,50 +16,51 @@ export default { { from: resolve(__dirname, "public/index.html") }, { from: resolve(__dirname, "public/wasmer.css") }, { from: resolve(__dirname, "public/worker.js") }, + { from: resolve(__dirname, "public/favicon.png") }, ], }), new WasmPackPlugin({ - crateDirectory: resolve(__dirname, './'), + crateDirectory: resolve(__dirname, './'), - // Check https://rustwasm.github.io/wasm-pack/book/commands/build.html for - // the available set of arguments. - // - // Optional space delimited arguments to appear before the wasm-pack - // command. Default arguments are `--verbose`. - args: '--log-level warn', - // Default arguments are `--typescript --target browser --mode normal`. - extraArgs: '--target web', + // Check https://rustwasm.github.io/wasm-pack/book/commands/build.html for + // the available set of arguments. + // + // Optional space delimited arguments to appear before the wasm-pack + // command. Default arguments are `--verbose`. + args: '--log-level warn', + // Default arguments are `--typescript --target browser --mode normal`. + extraArgs: '--target web', - // Optional array of absolute paths to directories, changes to which - // will trigger the build. - // watchDirectories: [ - // path.resolve(__dirname, "another-crate/src") - // ], + // Optional array of absolute paths to directories, changes to which + // will trigger the build. + // watchDirectories: [ + // path.resolve(__dirname, "another-crate/src") + // ], - // The same as the `--out-dir` option for `wasm-pack` - // outDir: "pkg", + // The same as the `--out-dir` option for `wasm-pack` + // outDir: "pkg", - // The same as the `--out-name` option for `wasm-pack` - // outName: "index", + // The same as the `--out-name` option for `wasm-pack` + // outName: "index", - // If defined, `forceWatch` will force activate/deactivate watch mode for - // `.rs` files. - // - // The default (not set) aligns watch mode for `.rs` files to Webpack's - // watch mode. - // forceWatch: true, + // If defined, `forceWatch` will force activate/deactivate watch mode for + // `.rs` files. + // + // The default (not set) aligns watch mode for `.rs` files to Webpack's + // watch mode. + // forceWatch: true, - // If defined, `forceMode` will force the compilation mode for `wasm-pack` - // - // Possible values are `development` and `production`. - // - // the mode `development` makes `wasm-pack` build in `debug` mode. - // the mode `production` makes `wasm-pack` build in `release` mode. - // forceMode: "development", + // If defined, `forceMode` will force the compilation mode for `wasm-pack` + // + // Possible values are `development` and `production`. + // + // the mode `development` makes `wasm-pack` build in `debug` mode. + // the mode `production` makes `wasm-pack` build in `release` mode. + // forceMode: "development", - // Controls plugin output verbosity, either 'info' or 'error'. - // Defaults to 'info'. - // pluginLogLevel: 'info' + // Controls plugin output verbosity, either 'info' or 'error'. + // Defaults to 'info'. + // pluginLogLevel: 'info' }), ], devServer: { diff --git a/lib/wasix/src/fs/mod.rs b/lib/wasix/src/fs/mod.rs index deec998e59e..2f14db8c410 100644 --- a/lib/wasix/src/fs/mod.rs +++ b/lib/wasix/src/fs/mod.rs @@ -7,14 +7,16 @@ use std::{ collections::{HashMap, HashSet, VecDeque}, ops::{Deref, DerefMut}, path::{Component, Path, PathBuf}, + pin::Pin, sync::{ atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering}, Arc, Mutex, RwLock, Weak, }, + task::{Context, Poll}, }; use crate::state::{Stderr, Stdin, Stdout}; -use futures::{future::BoxFuture, TryStreamExt}; +use futures::{future::BoxFuture, Future, TryStreamExt}; #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; use tokio::io::AsyncWriteExt; @@ -1526,35 +1528,52 @@ impl WasiFs { pub async fn flush(&self, fd: WasiFd) -> Result<(), Errno> { match fd { __WASI_STDIN_FILENO => (), - __WASI_STDOUT_FILENO => WasiInodes::stdout_mut(&self.fd_map) - .map_err(fs_error_into_wasi_err)? - .flush() - .await - .map_err(map_io_err)?, - __WASI_STDERR_FILENO => WasiInodes::stderr_mut(&self.fd_map) - .map_err(fs_error_into_wasi_err)? - .flush() - .await - .map_err(map_io_err)?, + __WASI_STDOUT_FILENO => { + let mut file = + WasiInodes::stdout_mut(&self.fd_map).map_err(fs_error_into_wasi_err)?; + file.flush().await.map_err(map_io_err)? + } + __WASI_STDERR_FILENO => { + let mut file = + WasiInodes::stderr_mut(&self.fd_map).map_err(fs_error_into_wasi_err)?; + file.flush().await.map_err(map_io_err)? + } _ => { let fd = self.get_fd(fd)?; if fd.rights.contains(Rights::FD_DATASYNC) { return Err(Errno::Access); } - let guard = fd.inode.read(); - match guard.deref() { - Kind::File { - handle: Some(file), .. - } => { - let mut file = file.write().unwrap(); - file.flush().await.map_err(|_| Errno::Io)? + let work = { + let guard = fd.inode.read(); + match guard.deref() { + Kind::File { + handle: Some(file), .. + } => { + struct FlushPoller { + file: Arc>>, + } + impl Future for FlushPoller { + type Output = Result<(), Errno>; + fn poll( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll { + let mut file = self.file.write().unwrap(); + Pin::new(file.as_mut()) + .poll_flush(cx) + .map_err(|_| Errno::Io) + } + } + FlushPoller { file: file.clone() } + } + // TODO: verify this behavior + Kind::Dir { .. } => return Err(Errno::Isdir), + Kind::Buffer { .. } => return Ok(()), + _ => return Err(Errno::Io), } - // TODO: verify this behavior - Kind::Dir { .. } => return Err(Errno::Isdir), - Kind::Buffer { .. } => (), - _ => return Err(Errno::Io), - } + }; + work.await? } } Ok(()) diff --git a/lib/wasix/src/lib.rs b/lib/wasix/src/lib.rs index d18ef45cdcc..d1e72b24798 100644 --- a/lib/wasix/src/lib.rs +++ b/lib/wasix/src/lib.rs @@ -677,10 +677,6 @@ fn import_object_for_all_wasi_versions( "wasix_64v1" => exports_wasix_64v1, }; - for import in module.imports() { - tracing::trace!("import {}.{}", import.module(), import.name()); - } - // TODO: clean this up! cfg_if::cfg_if! { if #[cfg(feature = "sys")] { diff --git a/lib/wasix/src/runtime/package_loader/builtin_loader.rs b/lib/wasix/src/runtime/package_loader/builtin_loader.rs index 18ade402332..c559c030050 100644 --- a/lib/wasix/src/runtime/package_loader/builtin_loader.rs +++ b/lib/wasix/src/runtime/package_loader/builtin_loader.rs @@ -30,7 +30,7 @@ use crate::{ pub struct BuiltinPackageLoader { client: Arc, in_memory: InMemoryCache, - fs: FileSystemCache, + cache: Option, } impl BuiltinPackageLoader { @@ -44,9 +44,17 @@ impl BuiltinPackageLoader { client: Arc, ) -> Self { BuiltinPackageLoader { - fs: FileSystemCache { + cache: Some(FileSystemCache { cache_dir: cache_dir.into(), - }, + }), + in_memory: InMemoryCache::default(), + client, + } + } + + pub fn new_only_client(client: Arc) -> Self { + BuiltinPackageLoader { + cache: None, in_memory: InMemoryCache::default(), client, } @@ -71,11 +79,13 @@ impl BuiltinPackageLoader { return Ok(Some(cached)); } - if let Some(cached) = self.fs.lookup(hash).await? { - // Note: We want to propagate it to the in-memory cache, too - tracing::debug!("Copying from the filesystem cache to the in-memory cache"); - self.in_memory.save(&cached, *hash); - return Ok(Some(cached)); + if let Some(cache) = self.cache.as_ref() { + if let Some(cached) = cache.lookup(hash).await? { + // Note: We want to propagate it to the in-memory cache, too + tracing::debug!("Copying from the filesystem cache to the in-memory cache"); + self.in_memory.save(&cached, *hash); + return Ok(Some(cached)); + } } Ok(None) @@ -134,33 +144,6 @@ impl BuiltinPackageLoader { Ok(body.into()) } - - #[tracing::instrument(level = "debug", skip_all)] - async fn save_and_load_as_mmapped( - &self, - webc: &[u8], - dist: &DistributionInfo, - ) -> Result { - // First, save it to disk - self.fs.save(webc, dist).await?; - - // Now try to load it again. The resulting container should use - // a memory-mapped file rather than an in-memory buffer. - match self.fs.lookup(&dist.webc_sha256).await? { - Some(container) => { - // we also want to make sure it's in the in-memory cache - self.in_memory.save(&container, dist.webc_sha256); - - Ok(container) - } - None => { - // Something really weird has occurred and we can't see the - // saved file. Just error out and let the fallback code do its - // thing. - Err(Error::msg("Unable to load the downloaded memory from disk")) - } - } - } } #[async_trait::async_trait] @@ -188,30 +171,34 @@ impl PackageLoader for BuiltinPackageLoader { // We want to cache the container we downloaded, but we want to do it // in a smart way to keep memory usage down. - match self.save_and_load_as_mmapped(&bytes, &summary.dist).await { - Ok(container) => { - tracing::debug!("Cached to disk"); - // The happy path - we've saved to both caches and loaded the - // container from disk (hopefully using mmap) so we're done. - return Ok(container); - } - Err(e) => { - tracing::warn!( - error=&*e, - pkg.name=%summary.pkg.name, - pkg.version=%summary.pkg.version, - pkg.hash=%summary.dist.webc_sha256, - pkg.url=%summary.dist.webc, - "Unable to save the downloaded package to disk", - ); - // The sad path - looks like we'll need to keep the whole thing - // in memory. - let container = Container::from_bytes(bytes)?; - // We still want to cache it, of course - self.in_memory.save(&container, summary.dist.webc_sha256); - Ok(container) + if let Some(cache) = &self.cache { + match cache.save_and_load_as_mmapped(&bytes, &summary.dist).await { + Ok(container) => { + tracing::debug!("Cached to disk"); + self.in_memory.save(&container, summary.dist.webc_sha256); + // The happy path - we've saved to both caches and loaded the + // container from disk (hopefully using mmap) so we're done. + return Ok(container); + } + Err(e) => { + tracing::warn!( + error=&*e, + pkg.name=%summary.pkg.name, + pkg.version=%summary.pkg.version, + pkg.hash=%summary.dist.webc_sha256, + pkg.url=%summary.dist.webc, + "Unable to save the downloaded package to disk", + ); + } } } + + // The sad path - looks like we don't have a filesystem cache so we'll + // need to keep the whole thing in memory. + let container = Container::from_bytes(bytes)?; + // We still want to cache it in memory, of course + self.in_memory.save(&container, summary.dist.webc_sha256); + Ok(container) } async fn load_package_tree( @@ -293,6 +280,28 @@ impl FileSystemCache { Ok(()) } + #[tracing::instrument(level = "debug", skip_all)] + async fn save_and_load_as_mmapped( + &self, + webc: &[u8], + dist: &DistributionInfo, + ) -> Result { + // First, save it to disk + self.save(webc, dist).await?; + + // Now try to load it again. The resulting container should use + // a memory-mapped file rather than an in-memory buffer. + match self.lookup(&dist.webc_sha256).await? { + Some(container) => Ok(container), + None => { + // Something really weird has occurred and we can't see the + // saved file. Just error out and let the fallback code do its + // thing. + Err(Error::msg("Unable to load the downloaded memory from disk")) + } + } + } + fn path(&self, hash: &WebcHash) -> PathBuf { let hash = hash.as_bytes(); let mut filename = String::with_capacity(hash.len() * 2); @@ -401,7 +410,11 @@ mod tests { let manifest = container.manifest(); assert_eq!(manifest.entrypoint.as_deref(), Some("python")); // it should have been automatically saved to disk - let path = loader.fs.path(&summary.dist.webc_sha256); + let path = loader + .cache + .as_ref() + .unwrap() + .path(&summary.dist.webc_sha256); assert!(path.exists()); assert_eq!(std::fs::read(&path).unwrap(), PYTHON); // and cached in memory for next time diff --git a/lib/wasix/src/runtime/task_manager/mod.rs b/lib/wasix/src/runtime/task_manager/mod.rs index 7bb853bb796..f04cd3ee791 100644 --- a/lib/wasix/src/runtime/task_manager/mod.rs +++ b/lib/wasix/src/runtime/task_manager/mod.rs @@ -23,6 +23,9 @@ pub enum SpawnMemoryType<'a> { // TODO: is there a way to get rid of the memory reference ShareMemory(Memory, StoreRef<'a>), // TODO: is there a way to get rid of the memory reference + // Note: The message sender is triggered once the memory + // has been copied, this makes sure its not modified until + // its been properly copied CopyMemory(Memory, StoreRef<'a>), } @@ -45,6 +48,9 @@ pub struct TaskWasmRunProperties { /// Callback that will be invoked pub type TaskWasmRun = dyn FnOnce(TaskWasmRunProperties) + Send + 'static; +/// Callback that will be invoked +pub type TaskExecModule = dyn FnOnce(Module) + Send + 'static; + /// Represents a WASM task that will be executed on a dedicated thread pub struct TaskWasm<'a, 'b> { pub run: Box, diff --git a/lib/wasix/src/state/builder.rs b/lib/wasix/src/state/builder.rs index dab216904ac..cf7937b7237 100644 --- a/lib/wasix/src/state/builder.rs +++ b/lib/wasix/src/state/builder.rs @@ -743,6 +743,7 @@ impl WasiEnvBuilder { thread: None, call_initialize: true, can_deep_sleep: false, + extra_tracing: true, }; Ok(init) diff --git a/lib/wasix/src/state/env.rs b/lib/wasix/src/state/env.rs index 44b17b6c103..516461d71ba 100644 --- a/lib/wasix/src/state/env.rs +++ b/lib/wasix/src/state/env.rs @@ -7,6 +7,7 @@ use std::{ }; use derivative::Derivative; +use futures::future::BoxFuture; use rand::Rng; use tracing::{trace, warn}; use virtual_fs::{AsyncWriteExt, FileSystem, FsError, VirtualFile}; @@ -31,7 +32,7 @@ use crate::{ thread::{WasiMemoryLayout, WasiThread, WasiThreadHandle, WasiThreadId}, }, runtime::{resolver::PackageSpecifier, SpawnMemoryType}, - syscalls::{__asyncify_light, platform_clock_time_get}, + syscalls::platform_clock_time_get, Runtime, VirtualTaskManager, WasiControlPlane, WasiEnvBuilder, WasiError, WasiFunctionEnv, WasiRuntimeError, WasiStateCreationError, WasiVFork, }; @@ -226,6 +227,9 @@ pub struct WasiEnvInit { /// Indicates if the calling environment is capable of deep sleeping pub can_deep_sleep: bool, + + /// Indicates if extra tracing should be output + pub extra_tracing: bool, } impl WasiEnvInit { @@ -261,6 +265,7 @@ impl WasiEnvInit { thread: None, call_initialize: self.call_initialize, can_deep_sleep: self.can_deep_sleep, + extra_tracing: false, } } } @@ -444,6 +449,12 @@ impl WasiEnv { let call_initialize = init.call_initialize; let spawn_type = init.memory_ty.take(); + if init.extra_tracing { + for import in module.imports() { + tracing::trace!("import {}.{}", import.module(), import.name()); + } + } + let env = Self::from_init(init)?; let pid = env.process.pid(); @@ -1000,39 +1011,52 @@ impl WasiEnv { /// Cleans up all the open files (if this is the main thread) #[allow(clippy::await_holding_lock)] pub fn blocking_cleanup(&self, exit_code: Option) { - __asyncify_light(self, None, async { - self.cleanup(exit_code).await; - Ok(()) - }) - .ok(); + let cleanup = self.cleanup(exit_code); + + #[cfg(feature = "js")] + self.tasks() + .task_shared(Box::new(|| { + Box::pin(async move { + cleanup.await; + }) + })) + .ok(); + + #[cfg(feature = "sys")] + self.tasks().block_on(cleanup); } /// Cleans up all the open files (if this is the main thread) #[allow(clippy::await_holding_lock)] - pub async fn cleanup(&self, exit_code: Option) { + pub fn cleanup(&self, exit_code: Option) -> BoxFuture<'static, ()> { const CLEANUP_TIMEOUT: Duration = Duration::from_secs(10); // If this is the main thread then also close all the files if self.thread.is_main() { trace!("wasi[{}]:: cleaning up open file handles", self.pid()); - // Perform the clean operation using the asynchronous runtime - let timeout = self.tasks().sleep_now(CLEANUP_TIMEOUT); - tokio::select! { - _ = timeout => { - tracing::warn!( - "WasiEnv::cleanup has timed out after {CLEANUP_TIMEOUT:?}" - ); - }, - _ = self.state.fs.close_all() => { } - } - // Now send a signal that the thread is terminated self.process.signal_process(Signal::Sigquit); // Terminate the process let exit_code = exit_code.unwrap_or_else(|| Errno::Canceled.into()); self.process.terminate(exit_code); + + let timeout = self.tasks().sleep_now(CLEANUP_TIMEOUT); + let state = self.state.clone(); + Box::pin(async move { + // Perform the clean operation using the asynchronous runtime + tokio::select! { + _ = timeout => { + tracing::warn!( + "WasiEnv::cleanup has timed out after {CLEANUP_TIMEOUT:?}" + ); + }, + _ = state.fs.close_all() => { } + } + }) + } else { + Box::pin(async {}) } } } diff --git a/lib/wasix/src/state/func_env.rs b/lib/wasix/src/state/func_env.rs index 8d5c4520c8f..c6aaffdcf1d 100644 --- a/lib/wasix/src/state/func_env.rs +++ b/lib/wasix/src/state/func_env.rs @@ -207,7 +207,7 @@ impl WasiFunctionEnv { /// code pub fn cleanup(&self, store: &mut impl AsStoreMut, exit_code: Option) { trace!( - "wasi[{}:{}]::cleanup - destroying local thread variables", + "wasi[{}:{}]::cleanup", self.data(store).pid(), self.data(store).tid() ); diff --git a/lib/wasix/src/syscalls/wasix/proc_fork.rs b/lib/wasix/src/syscalls/wasix/proc_fork.rs index d44a93b54f4..2f916a330e7 100644 --- a/lib/wasix/src/syscalls/wasix/proc_fork.rs +++ b/lib/wasix/src/syscalls/wasix/proc_fork.rs @@ -30,9 +30,13 @@ pub fn proc_fork( // If we were just restored then we need to return the value instead if let Some(result) = unsafe { handle_rewind::(&mut ctx) } { if result.pid == 0 { - trace!("handle_rewind - i am child"); + trace!("handle_rewind - i am child (ret={})", result.ret); } else { - trace!("handle_rewind - i am parent (child={})", result.pid); + trace!( + "handle_rewind - i am parent (child={}, ret={})", + result.pid, + result.ret + ); } let memory = unsafe { ctx.data().memory_view(&ctx) }; wasi_try_mem_ok!(pid_ptr.write(&memory, result.pid)); @@ -127,12 +131,15 @@ pub fn proc_fork( // Perform the unwind action let snapshot = capture_snapshot(&mut ctx.as_store_mut()); unwind::(ctx, move |mut ctx, mut memory_stack, rewind_stack| { + let tasks = ctx.data().tasks().clone(); let span = debug_span!( "unwind", memory_stack_len = memory_stack.len(), rewind_stack_len = rewind_stack.len() ); let _span_guard = span.enter(); + let memory_stack = memory_stack.freeze(); + let rewind_stack = rewind_stack.freeze(); // Grab all the globals and serialize them let store_data = snapshot.serialize().unwrap(); @@ -167,8 +174,8 @@ pub fn proc_fork( let (data, mut store) = ctx.data_and_store_mut(); match rewind::( ctx, - child_memory_stack.freeze(), - child_rewind_stack.freeze(), + child_memory_stack, + child_rewind_stack, store_data.clone(), ForkResult { pid: 0, @@ -203,14 +210,14 @@ pub fn proc_fork( ); err }) - .ok() + .ok(); }; // Rewind the stack and carry on match rewind::( ctx, - memory_stack.freeze(), - rewind_stack.freeze(), + memory_stack, + rewind_stack, store_data, ForkResult { pid: child_pid.raw() as Pid, diff --git a/lib/wasix/src/utils/owned_mutex_guard.rs b/lib/wasix/src/utils/owned_mutex_guard.rs index 430d0fd3500..4edc7103d12 100644 --- a/lib/wasix/src/utils/owned_mutex_guard.rs +++ b/lib/wasix/src/utils/owned_mutex_guard.rs @@ -97,6 +97,8 @@ pub(crate) struct OwnedRwLockReadGuard { ownership: Arc>, } +unsafe impl Send for OwnedRwLockReadGuard where T: Send {} + impl Drop for OwnedRwLockReadGuard where T: Sized, @@ -173,6 +175,8 @@ pub(crate) struct OwnedRwLockWriteGuard { ownership: Arc>, } +unsafe impl Send for OwnedRwLockWriteGuard where T: Send {} + impl Drop for OwnedRwLockWriteGuard where T: Sized,