diff options
| author | har7an <99636919+har7an@users.noreply.github.com> | 2026-02-19 11:59:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-19 12:59:14 +0100 |
| commit | 3a9cf0a6d6b98dee0246e6fa5a539e1f6d546084 (patch) | |
| tree | 5021050e1d0984de3ca27295bd6ed6b83058d9c1 /zellij-utils/src/kdl | |
| parent | fix: tab-bar wrapping for extremely small widths (#4728) (diff) | |
| download | sl0ppij-3a9cf0a6d6b98dee0246e6fa5a539e1f6d546084.tar.gz sl0ppij-3a9cf0a6d6b98dee0246e6fa5a539e1f6d546084.tar.xz sl0ppij-3a9cf0a6d6b98dee0246e6fa5a539e1f6d546084.zip | |
Purge `async_std` from the codebase (#4672)
* build(utils): Replace `async_std` with `tokio`
removing an entire async runtime from the dependency tree. `tokio` has
previously been required by `wasmtime` in any case, and the version of
async_std we used was ancient (1.3) and relied on unstable features.
* build(server): Remove `async_std` from the codebase
and replace it with `tokio` instead, which is already used by
`zellij-utils` and `wasmtime`.
* build(server): Remove dead dependency.
* fix: Don't keep an async runtime in the `zellij-utils` subcrate
but prefer to reuse an existing runtime from a caller instead. If no
such runtime exists, create an ephemeral runtime on the current thread
to run async tasks instead. Ideally, the functions needing the async
task would be async themselves, but these are called by the `Layout`
code based on a `ClientMsg`, and the code handling this currently lives
in `zellij-utils` and is sync itself. So, for the time being, there is
no way around this runtime requirement without a huge refactoring.
* refactor(server): Unclutter async tasks
in a few cases where either blocking code was called in an (unnecessary)
async task or an entire thread was spawned to block on the result of an
async task.
* docs(CHANGELOG): Mention PR 4672
* fix(server): Don't terminate when killing a panes children fails
but log the error and continue instead.
* feat: Add config option for number of async tasks to spawn
so users on machines with few resources can configure a task limit
without requiring recompilation.
Diffstat (limited to 'zellij-utils/src/kdl')
3 files changed, 60 insertions, 0 deletions
diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index 99e539cc..2fd4caa8 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -2708,6 +2708,21 @@ impl Options { let post_command_discovery_hook = kdl_property_first_arg_as_string_or_error!(kdl_options, "post_command_discovery_hook") .map(|(hook, _entry)| hook.to_string()); + let client_async_worker_tasks = + match kdl_property_first_arg_as_i64_or_error!(kdl_options, "client_async_worker_tasks") + { + Some((value, _)) if value >= 0 => Some(value as usize), + Some((value, entry)) => { + return Err(kdl_parsing_error!( + format!( + "Number of client async worker tasks must be greater than 0, found '{}'", + value + ), + entry + )); + }, + None => None, + }; Ok(Options { simplified_ui, @@ -2751,6 +2766,7 @@ impl Options { web_server_key, enforce_https_for_localhost, post_command_discovery_hook, + client_async_worker_tasks, }) } pub fn from_string(stringified_keybindings: &String) -> Result<Self, ConfigError> { @@ -3961,6 +3977,32 @@ impl Options { None } } + fn client_async_worker_tasks_to_kdl(&self, add_comments: bool) -> Option<KdlNode> { + let comment_text = r#" +// Number of async worker tasks to spawn per active client. +// +// Allocating few tasks may result in resource contention and lags. Small values (around 4) should +// typically work best. Set to 0 to use the number of (physical) CPU cores. +// Note: This only applies to web clients at the moment."#; + let create_node = |node_value: usize| -> KdlNode { + let mut node = KdlNode::new("client_async_worker_tasks"); + node.push(KdlValue::Base10(node_value as i64)); + node + }; + if let Some(client_async_worker_tasks) = self.client_async_worker_tasks { + let mut node = create_node(client_async_worker_tasks); + if add_comments { + node.set_leading(format!("{}\n", comment_text)); + } + Some(node) + } else if add_comments { + let mut node = create_node(4usize); + node.set_leading(format!("{}\n// ", comment_text)); + Some(node) + } else { + None + } + } pub fn to_kdl(&self, add_comments: bool) -> Vec<KdlNode> { let mut nodes = vec![]; if let Some(simplified_ui_node) = self.simplified_ui_to_kdl(add_comments) { @@ -4094,6 +4136,10 @@ impl Options { { nodes.push(post_command_discovery_hook); } + if let Some(client_async_worker_tasks) = self.client_async_worker_tasks_to_kdl(add_comments) + { + nodes.push(client_async_worker_tasks); + } nodes } } diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__bare_config_from_default_assets_to_string_with_comments.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__bare_config_from_default_assets_to_string_with_comments.snap index 2faf486d..3d9cd208 100644 --- a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__bare_config_from_default_assets_to_string_with_comments.snap +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__bare_config_from_default_assets_to_string_with_comments.snap @@ -559,3 +559,10 @@ web_client { // can be useful for removing wrappers around commands // Note: be sure to escape backslashes and similar characters properly // post_command_discovery_hook "echo $RESURRECT_COMMAND | sed <your_regex_here>" + +// Number of async worker tasks to spawn per active client. +// +// Allocating few tasks may result in resource contention and lags. Small values (around 4) should +// typically work best. Set to 0 to use the number of (physical) CPU cores. +// Note: This only applies to web clients at the moment. +// client_async_worker_tasks 4 diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__config_options_to_string_with_comments.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__config_options_to_string_with_comments.snap index 7d45fb9d..18293ffb 100644 --- a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__config_options_to_string_with_comments.snap +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__config_options_to_string_with_comments.snap @@ -272,3 +272,10 @@ web_sharing "disabled" // can be useful for removing wrappers around commands // Note: be sure to escape backslashes and similar characters properly // post_command_discovery_hook "echo $RESURRECT_COMMAND | sed <your_regex_here>" + +// Number of async worker tasks to spawn per active client. +// +// Allocating few tasks may result in resource contention and lags. Small values (around 4) should +// typically work best. Set to 0 to use the number of (physical) CPU cores. +// Note: This only applies to web clients at the moment. +// client_async_worker_tasks 4 |
