diff options
author | KOVACS Tamas <ktamas@fastmail.fm> | 2021-05-26 00:56:27 +0200 |
---|---|---|
committer | KOVACS Tamas <ktamas@fastmail.fm> | 2021-05-27 23:42:15 +0200 |
commit | 8ccf3d61a02e8df8c45e70b230d4cf3266195f0b (patch) | |
tree | 80069d01aead99ed927abd4fa3fc8c2b47a9e4c6 /src | |
parent | 0c0355dbc6e0159a72b0f55c7aabb83d76c2312a (diff) |
fix: use bounded queue between pty and screen
Pty reads a command's output and feeds it to Screen using an unbounded
queue.
However, if the command produces output faster than what `Screen` can
render, `Pty` still pushes it on the queue, causing it to grow
indefinitely, resulting in high memory usage and latency.
This patch fixes this by using a bounded queue between Pty and Screen,
so if Screen can't keep up with Pty, the queue will fill up, exerting
back pressure on Pty, making it read the command's output only as fast
as Screen renders it.
The unbounded queue is kept between Screen and producers other than Pty
to avoid a deadlock such as this scenario:
* pty thread filling up screen queue as soon as screen thread pops
something from it
* wasm thread is processing a Render instruction, blocking on the screen
queue
* screen thread is trying to render a plugin pane. It attempts to send a
Render insturction to the blocked wasm thread running the plugin.
This patch also adds a generous amount of sleeps to the integration
tests as having backpressure changes the timing of how instructions are
processed.
Fixes #525.
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/integration/close_pane.rs | 6 | ||||
-rw-r--r-- | src/tests/integration/resize_down.rs | 5 | ||||
-rw-r--r-- | src/tests/integration/resize_left.rs | 3 | ||||
-rw-r--r-- | src/tests/integration/resize_right.rs | 3 | ||||
-rw-r--r-- | src/tests/integration/resize_up.rs | 5 |
5 files changed, 21 insertions, 1 deletions
diff --git a/src/tests/integration/close_pane.rs b/src/tests/integration/close_pane.rs index b5ba7f198..598815145 100644 --- a/src/tests/integration/close_pane.rs +++ b/src/tests/integration/close_pane.rs @@ -9,7 +9,7 @@ use crate::CliArgs; use crate::tests::utils::commands::{ CLOSE_PANE_IN_PANE_MODE, ESC, MOVE_FOCUS_IN_PANE_MODE, PANE_MODE, QUIT, RESIZE_DOWN_IN_RESIZE_MODE, RESIZE_LEFT_IN_RESIZE_MODE, RESIZE_MODE, RESIZE_UP_IN_RESIZE_MODE, - SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, + SLEEP, SPLIT_DOWN_IN_PANE_MODE, SPLIT_RIGHT_IN_PANE_MODE, }; use zellij_utils::input::config::Config; @@ -404,6 +404,7 @@ pub fn close_pane_with_multiple_panes_above_it_away_from_screen_edges() { &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -464,6 +465,7 @@ pub fn close_pane_with_multiple_panes_below_it_away_from_screen_edges() { &PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -530,6 +532,7 @@ pub fn close_pane_with_multiple_panes_to_the_left_away_from_screen_edges() { &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -592,6 +595,7 @@ pub fn close_pane_with_multiple_panes_to_the_right_away_from_screen_edges() { &PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, diff --git a/src/tests/integration/resize_down.rs b/src/tests/integration/resize_down.rs index 4ef45a069..e5d35c266 100644 --- a/src/tests/integration/resize_down.rs +++ b/src/tests/integration/resize_down.rs @@ -438,6 +438,7 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_DOWN_IN_RESIZE_MODE, @@ -491,6 +492,7 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -547,10 +549,12 @@ pub fn resize_down_with_panes_above_aligned_left_and_right_with_panes_to_the_lef &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -619,6 +623,7 @@ pub fn resize_down_with_panes_below_aligned_left_and_right_with_to_the_left_and_ &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, diff --git a/src/tests/integration/resize_left.rs b/src/tests/integration/resize_left.rs index 1b8205019..564d5c605 100644 --- a/src/tests/integration/resize_left.rs +++ b/src/tests/integration/resize_left.rs @@ -416,6 +416,7 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_current_pa &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, @@ -469,6 +470,7 @@ pub fn resize_left_with_panes_to_the_right_aligned_top_and_bottom_with_current_p &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -529,6 +531,7 @@ pub fn resize_left_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abov &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, diff --git a/src/tests/integration/resize_right.rs b/src/tests/integration/resize_right.rs index 44601f2cd..716ed128c 100644 --- a/src/tests/integration/resize_right.rs +++ b/src/tests/integration/resize_right.rs @@ -416,6 +416,7 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_current_p &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_RIGHT_IN_RESIZE_MODE, @@ -469,6 +470,7 @@ pub fn resize_right_with_panes_to_the_right_aligned_top_and_bottom_with_current_ &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -529,6 +531,7 @@ pub fn resize_right_with_panes_to_the_left_aligned_top_and_bottom_with_panes_abo &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_RIGHT_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, diff --git a/src/tests/integration/resize_up.rs b/src/tests/integration/resize_up.rs index 9aca8d5a2..0097756a8 100644 --- a/src/tests/integration/resize_up.rs +++ b/src/tests/integration/resize_up.rs @@ -432,6 +432,7 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &RESIZE_MODE, &RESIZE_UP_IN_RESIZE_MODE, @@ -485,6 +486,7 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_current_pane() { &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -541,10 +543,12 @@ pub fn resize_up_with_panes_above_aligned_left_and_right_with_panes_to_the_left_ &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, @@ -613,6 +617,7 @@ pub fn resize_up_with_panes_below_aligned_left_and_right_with_to_the_left_and_ri &RESIZE_LEFT_IN_RESIZE_MODE, &RESIZE_LEFT_IN_RESIZE_MODE, &PANE_MODE, + &SLEEP, &SPLIT_DOWN_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, &MOVE_FOCUS_IN_PANE_MODE, |