-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Change wasmtime wast to be powered from JSON AST
#11113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
My rough hope here is that we can at least use this to run scripts during development, but I'm also curious what others' thoughts on this are. |
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
fitzgen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I like the approach.
We can potentially try bincode or peekpoke or something for the serialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a comment at the top with an example usage, showing the CLI args expected and all that?
This commit is a refactoring of the `wasmtime-wast` crate to use the `json-from-wast` crate added in bytecodealliance/wasm-tools#2247 instead of the `wast` crate directly. The primary motivation for this PR is to make spec tests more suitable for running inside of Miri. There are two primary factors in how Miri is slow with wast tests today: * Compiling WebAssembly modules. These are all embedded throughout `*.wast` files and basically need to be precompiled to run in Miri. * Parsing the `*.wast` script itself. The scripts are generally quite large in the upstream spec test suite and parsing the script requires parsing all modules as well, so this can take quite some time. The goal of this commit was to leverage `json-from-wast` to perform much of the heavy lifting on the host and then have a "cheap" parse step in Miri which deserializes the JSON and runs precompiled `*.cwasm` files. The main change then required of `wasmtime-wast` was to use the JSON AST as its "IR" instead of `wast` directly. The actual transformation of the `wasmtime-wast` crate isn't too bad, mostly just some refactorings here and there. A new `./ci/miri-wast.sh` script is added which first runs on native with `wasmtime wast --precompile-save` and then runs in Miri with `wasmtime wast --precompile-load`. In this manner I was able to get a number of spec test `*.wast` files running in Miri. Unfortunately, though, Miri is still far too slow to run in CI. One major bottleneck is that the `*.json` files are pretty large and take a nontrivial amount of time to parse. Another issue is that these tests run a fair bit of code which with Miri's ~million-x slowdown. For the first problem I tried using other more-binary serialization formats but the JSON AST is unfortunately not compatible with many of them (e.g. `postcard`, which we use for Wasmtime, is not compatible with the JSON AST's structure in Rust types). For the latter I'm not sure what to do... In the end I figured this might be a reasonable refactoring to go ahead and land anyway. It at least enables running `*.wast` tests in Miri while removing a large part of the runtime slowdown. We can in theory still allow-list some tests to run as they don't all take forever. Some future breakthrough is still going to be required though to run everything through Miri.
|
Ok with the publication of wasm-tools this is now ready to go. I tried |
Pull Request is not mergeable
…11113) * Change `wasmtime wast` to be powered from JSON AST This commit is a refactoring of the `wasmtime-wast` crate to use the `json-from-wast` crate added in bytecodealliance/wasm-tools#2247 instead of the `wast` crate directly. The primary motivation for this PR is to make spec tests more suitable for running inside of Miri. There are two primary factors in how Miri is slow with wast tests today: * Compiling WebAssembly modules. These are all embedded throughout `*.wast` files and basically need to be precompiled to run in Miri. * Parsing the `*.wast` script itself. The scripts are generally quite large in the upstream spec test suite and parsing the script requires parsing all modules as well, so this can take quite some time. The goal of this commit was to leverage `json-from-wast` to perform much of the heavy lifting on the host and then have a "cheap" parse step in Miri which deserializes the JSON and runs precompiled `*.cwasm` files. The main change then required of `wasmtime-wast` was to use the JSON AST as its "IR" instead of `wast` directly. The actual transformation of the `wasmtime-wast` crate isn't too bad, mostly just some refactorings here and there. A new `./ci/miri-wast.sh` script is added which first runs on native with `wasmtime wast --precompile-save` and then runs in Miri with `wasmtime wast --precompile-load`. In this manner I was able to get a number of spec test `*.wast` files running in Miri. Unfortunately, though, Miri is still far too slow to run in CI. One major bottleneck is that the `*.json` files are pretty large and take a nontrivial amount of time to parse. Another issue is that these tests run a fair bit of code which with Miri's ~million-x slowdown. For the first problem I tried using other more-binary serialization formats but the JSON AST is unfortunately not compatible with many of them (e.g. `postcard`, which we use for Wasmtime, is not compatible with the JSON AST's structure in Rust types). For the latter I'm not sure what to do... In the end I figured this might be a reasonable refactoring to go ahead and land anyway. It at least enables running `*.wast` tests in Miri while removing a large part of the runtime slowdown. We can in theory still allow-list some tests to run as they don't all take forever. Some future breakthrough is still going to be required though to run everything through Miri. * Document usage * Adjust lint * Fix CI issues
This commit is a refactoring of the
wasmtime-wastcrate to use thejson-from-wastcrate added in bytecodealliance/wasm-tools#2247 instead of thewastcrate directly. The primary motivation for this PR is to make spec tests more suitable for running inside of Miri. There are two primary factors in how Miri is slow with wast tests today:Compiling WebAssembly modules. These are all embedded throughout
*.wastfiles and basically need to be precompiled to run in Miri.Parsing the
*.wastscript itself. The scripts are generally quite large in the upstream spec test suite and parsing the script requires parsing all modules as well, so this can take quite some time.The goal of this commit was to leverage
json-from-wastto perform much of the heavy lifting on the host and then have a "cheap" parse step in Miri which deserializes the JSON and runs precompiled*.cwasmfiles. The main change then required ofwasmtime-wastwas to use the JSON AST as its "IR" instead ofwastdirectly. The actual transformation of thewasmtime-wastcrate isn't too bad, mostly just some refactorings here and there.A new
./ci/miri-wast.shscript is added which first runs on native withwasmtime wast --precompile-saveand then runs in Miri withwasmtime wast --precompile-load. In this manner I was able to get a number of spec test*.wastfiles running in Miri.Unfortunately, though, Miri is still far too slow to run in CI. One major bottleneck is that the
*.jsonfiles are pretty large and take a nontrivial amount of time to parse. Another issue is that these tests run a fair bit of code which with Miri's ~million-x slowdown. For the first problem I tried using other more-binary serialization formats but the JSON AST is unfortunately not compatible with many of them (e.g.postcard, which we use for Wasmtime, is not compatible with the JSON AST's structure in Rust types). For the latter I'm not sure what to do...In the end I figured this might be a reasonable refactoring to go ahead and land anyway. It at least enables running
*.wasttests in Miri while removing a large part of the runtime slowdown. We can in theory still allow-list some tests to run as they don't all take forever. Some future breakthrough is still going to be required though to run everything through Miri.