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

Make the singlepass compiler opt-in through flags #2146

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ Note that the output is truncated at 100KB. This can be adjusted for the purpose
When running Zellij with the `--debug` flag, Zellij will dump a copy of all bytes received over the pty for each pane in: `/$temp_dir/zellij-<UID>/zellij-log/zellij-<pane_id>.log`. These might be useful when troubleshooting terminal issues.

## Testing plugins
Zellij by default uses a fast, non-optimized, compiler for WASM when running in debug mode. This can be overriden by using the `force_cranelift` feature flag, if you wish to reproduce the behavior of release mode.
Zellij allows the use of the [Singlepass](https://crates.io/crates/wasmer-compiler-singlepass) compiler for wasmer. This can enable great gains in compilation time of plugins in detriment of stability, notably on Arm64 architectures.

To enable the flag, run:
To enable the singlepass compiler, use the `singlepass` flag. E.g.:
```sh
cargo xtask run --cranelift
cargo xtask run --singlepass
```

## How we treat clippy lints
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ pkg-fmt = "tgz"
default = [ "zellij-utils/plugins_from_target" ]
disable_automatic_asset_installation = [ "zellij-utils/disable_automatic_asset_installation" ]
unstable = [ "zellij-client/unstable", "zellij-utils/unstable" ]
force_cranelift = [ "zellij-server/force_cranelift" ]
singlepass = [ "zellij-server/singlepass" ]
6 changes: 3 additions & 3 deletions xtask/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ xflags::xflags! {
cmd run {
/// Take plugins from here, skip building plugins. Passed to zellij verbatim
optional --data-dir path: PathBuf
/// Force the use of Cranelift for compiling WASM modules
optional --cranelift
/// Enable the singlepass compiler for WASM plugins
optional --singlepass
/// Arguments to pass after `cargo run --`
repeated args: OsString
}
Expand Down Expand Up @@ -176,7 +176,7 @@ pub struct Run {

pub data_dir: Option<PathBuf>,

pub cranelift: bool,
pub singlepass: bool,
}

#[derive(Debug)]
Expand Down
6 changes: 3 additions & 3 deletions xtask/src/pipelines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn install(sh: &Shell, flags: flags::Install) -> anyhow::Result<()> {
pub fn run(sh: &Shell, flags: flags::Run) -> anyhow::Result<()> {
let err_context = || format!("failed to run pipeline 'run' with args {flags:?}");

let cranelift = flags.cranelift.then_some(["--features", "force_cranelift"]);
let singlepass = flags.singlepass.then_some(["--features", "singlepass"]);

if let Some(ref data_dir) = flags.data_dir {
let data_dir = sh.current_dir().join(data_dir);
Expand All @@ -105,7 +105,7 @@ pub fn run(sh: &Shell, flags: flags::Run) -> anyhow::Result<()> {
.args(["--package", "zellij"])
.arg("--no-default-features")
.args(["--features", "disable_automatic_asset_installation"])
.args(cranelift.iter().flatten())
.args(singlepass.iter().flatten())
.args(["--", "--data-dir", &format!("{}", data_dir.display())])
.args(&flags.args)
.run()
Expand All @@ -124,7 +124,7 @@ pub fn run(sh: &Shell, flags: flags::Run) -> anyhow::Result<()> {
.and_then(|_| crate::cargo())
.and_then(|cargo| {
cmd!(sh, "{cargo} run")
.args(cranelift.iter().flatten())
.args(singlepass.iter().flatten())
.args(["--"])
.args(&flags.args)
.run()
Expand Down
4 changes: 2 additions & 2 deletions zellij-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ daemonize = "0.4.1"
serde_json = "1.0"
unicode-width = "0.1.8"
url = "2.2.2"
wasmer = { version = "2.3.0", features = ["singlepass"]}
wasmer = "2.3.0"
wasmer-wasi = "2.3.0"
cassowary = "0.3.0"
zellij-utils = { path = "../zellij-utils/", version = "0.34.5" }
Expand All @@ -37,4 +37,4 @@ semver = "0.11.0"
insta = "1.6.0"

[features]
force_cranelift = []
singlepass = ["wasmer/singlepass"]
4 changes: 2 additions & 2 deletions zellij-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,13 @@ fn init_session(
}
}

#[cfg(any(feature = "force_cranelift", not(debug_assertions)))]
#[cfg(not(feature = "singlepass"))]
fn get_store() -> Store {
log::info!("Compiling plugins using Cranelift");
Store::new(&wasmer::Universal::new(wasmer::Cranelift::default()).engine())
}

#[cfg(not(any(feature = "force_cranelift", not(debug_assertions))))]
#[cfg(feature = "singlepass")]
fn get_store() -> Store {
log::info!("Compiling plugins using Singlepass");
Store::new(&wasmer::Universal::new(wasmer::Singlepass::default()).engine())
Expand Down