-
Notifications
You must be signed in to change notification settings - Fork 37
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
WASM running of hydroflow #329
Comments
I've been slowly working through this in down time, current goal is to get a demo on the website |
The surface syntax parsing and processing should be good, but I anticipate issues with Tokio on WASM |
Oh yes true, I guess there are two issues: get the Hydroflow Language / Dedalus compilers to work on WASM, and get the Hydroflow runtime to work. Found https://github.com/shosti/wraft as a potentially interesting benchmark for the runtime; in principle we should be able to wire up WebRTC as the networking layer with Tokio on WASM. |
|
@tylerhou will look into this soon |
I took a brief look at this today. The latest version of Tokio has limited support for WASM including runtime: https://github.com/tokio-rs/tokio/blob/a7945b469d634cf205094d8a1661720358622cc0/tokio/src/lib.rs#L387. Our current version also supports all those features above but it is not documented (tested by compiling for WASM with those features enabled). For WASM we would need to not specify There are still two outstanding issues:
|
This is very exciting progress! For the second issue, I think we can add a |
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only once with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only once with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only once with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only once with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only once with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only once with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
Tests do not work yet; I have a followup PR. 1. Turn off diagnostics for non-proc-macro crates. Diagnostics don't work when building for WASM. The proc-macro crates that are compiled at compile time still enable diagonstics because they target the (presumably non-WASM) host architecture where diagonstics work. 2. Use version 2 for the Cargo feature resolver. The version 1 resolver does not treat proc-macro edges differently from regular dependency edges. That is, suppose we depend on package P transitively via both a proc-macro edge and a regular edge, and the proc-macro edge enables feature X but the regular edge does not. With the version 1 resolver, Cargo will compile P only once with X enabled (assuming same host and target arch). With the v2 resolver, Cargo will compile P (at least) twice; once with X enabled for the proc-macro crate, once with P disabled. In our project, P = {hydroflow_datalog_core, hydroflow_lang}, X = diagnostics. The version 1 resolver works for non-WASM builds (because diagnostics compiles fine), but for WASM builds the v1 resolver attempts to build hydroflow_datalog_core for WASM with diagnostics enabled (because of feature resolution). Note that enabling the v2 feature resolver should not change compile times: on non-WASM, diagnostics is always enabled so we only compile P once. On WASM builds, we would have compiled twice anyway (once for the host architecture for the proc-macro package, another for WASM). 3. Turn on only a subset of Tokio features when compiling for WASM. In particular, the WASM environment does not natively support threads and fails to compile with threading features enabled. 4. Manually enable the "js" feature for hydroflow/getrandom. See the comment in hydroflow/Cargo.toml.
(Compilation in WASM, i.e. running |
Works in general, networking (TCP analogous to websockets, other options as well), #1440 will be the main issue |
#1447 wasm hackathon branch |
Should be possible to do, but do we want to? Would be fun but maybe not high priority. Mentioned in slack briefly @shadaj
The text was updated successfully, but these errors were encountered: