Skip to content
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 threading #2517

Merged
merged 4 commits into from
Sep 23, 2024
Merged

Wasm threading #2517

merged 4 commits into from
Sep 23, 2024

Conversation

Twey
Copy link
Contributor

@Twey Twey commented Sep 19, 2024

Atop #2516.

Motivation

Since we rely on parallelism to execute contracts without deadlocking, we need to add parallelism on the Web client to mimic the behaviour of the native client.

Proposal

Add the wasm_thread library and use it to provide parallelism on the Web.

Note: this won't actually work in this repository as configured, because wasm_thread needs to be built with nightly Rust, and also have the following unstable target features enabled:

[target.wasm32-unknown-unknown]
rustflags = ["-C", "target-feature=+atomics,+bulk-memory,+mutable-globals"]

[unstable]
build-std = ["panic_abort", "std"]

Enabling these in this repository, though, will break the examples, since our native Wasm runtime can't handle the atomics instructions that rustc will output. Instead, we have enabled nightly here without the features, and will provide the flags when building from linera-web.

Test Plan

Tested by linera-web.

Release Plan

None.

Links

@Twey Twey force-pushed the wasm-thread branch 4 times, most recently from cd11041 to dab8d3e Compare September 19, 2024 21:34
Use the `wasm_thread` library to enable real `spawn_blocking` on the
Web in `linera_base::task`.
@Twey Twey marked this pull request as ready for review September 23, 2024 11:46
@@ -159,7 +162,7 @@ jobs:
| xargs -0 scripts/target/release/check_copyright_header
- name: Put lint toolchain file in place
run: |
ln -sf toolchains/lint/rust-toolchain.toml
ln -sf toolchains/nightly/rust-toolchain.toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line still needed at all then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we're still using the stable toolchain by default.

toolchains/nightly/rust-toolchain.toml Show resolved Hide resolved
linera-storage/build.rs Show resolved Hide resolved
spawn(async { task() })
let (send, recv) = oneshot::channel();
wasm_thread::spawn(move || {
let _ = send.send(task());
Copy link
Contributor

@ma2bd ma2bd Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the let _ = for? Are you suppressing a warning intentionally? (If yes, consider adding a comment. Otherwise, I'd suggest not to use let _ = in the first place.)

@Twey Twey merged commit 71de70b into linera-io:main Sep 23, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants