mirror of
https://github.com/wez/wezterm.git
synced 2024-09-20 03:09:06 +03:00
mux: make action parser buffer size configurable and smaller
Previously, we'd use a 1MB buffer both to read the output from the associated pty (blocking), and the same size buffer again to do the non-blocking read on top of that. For pathological cases (eg: cat 100MB+ files), we could build a resulting `Vec<Action>` with over 1mm entries and it could take as much as 100ms to apply those actions to the terminal model. This meant that the output could stutter/lag and appear to be processed more slowly. This commit introduces a configuration value for the buffer size for the second stage, and makes it 10KB in size. This helps to constrain the size of the Action vec and keeps the incremental processing costs down, while still managing the same throughput.
This commit is contained in:
parent
e165cdf210
commit
159abe5e28
@ -885,6 +885,13 @@ pub struct Config {
|
||||
#[serde(default = "default_ratelimit_line_prefetches_per_second")]
|
||||
pub ratelimit_mux_line_prefetches_per_second: u32,
|
||||
|
||||
/// The buffer size used by parse_buffered_data in the mux module.
|
||||
/// This should not be too large, otherwise the processing cost
|
||||
/// of applying a batch of actions to the terminal will be too
|
||||
/// high and the user experience will be laggy and less responsive.
|
||||
#[serde(default = "default_mux_output_parser_buffer_size")]
|
||||
pub mux_output_parser_buffer_size: usize,
|
||||
|
||||
#[serde(default)]
|
||||
pub keys: Vec<Key>,
|
||||
#[serde(
|
||||
@ -1755,6 +1762,10 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
fn default_mux_output_parser_buffer_size() -> usize {
|
||||
10 * 1024
|
||||
}
|
||||
|
||||
fn default_ratelimit_line_prefetches_per_second() -> u32 {
|
||||
10
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ fn send_actions_to_mux(pane_id: PaneId, dead: &Arc<AtomicBool>, actions: Vec<Act
|
||||
}
|
||||
|
||||
fn parse_buffered_data(pane_id: PaneId, dead: &Arc<AtomicBool>, mut rx: FileDescriptor) {
|
||||
let mut buf = vec![0; BUFSIZE];
|
||||
let mut buf = vec![0; configuration().mux_output_parser_buffer_size];
|
||||
let mut parser = termwiz::escape::parser::Parser::new();
|
||||
let mut actions = vec![];
|
||||
let mut hold = false;
|
||||
@ -149,6 +149,8 @@ fn parse_buffered_data(pane_id: PaneId, dead: &Arc<AtomicBool>, mut rx: FileDesc
|
||||
if !actions.is_empty() && !hold {
|
||||
send_actions_to_mux(pane_id, dead, std::mem::take(&mut actions));
|
||||
}
|
||||
|
||||
buf.resize(configuration().mux_output_parser_buffer_size, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user