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.
* refactor(fakes): clean up add_terminal_input
* refactor(fakes): append whole buf to output_buffer in FakeStdoutWriter::write
* refactor(fakes): append whole buf to output_buffer in FakeInputOutput::write_to_tty_stdin
* fix(fakes): allow partial reads in read_from_tty_stdout
This patch fixes two bugs in read_from_tty_stdout:
* if there was a partial read (ie. `bytes.read_position` is not 0 but
less than `bytes.content.len()`), subsequent calls to would fill `buf`
starting at index `bytes.read_position` instead of 0, leaving range
0..`bytes.read_position` untouched.
* if `buf` was smaller than `bytes.content.len()`, a panic would occur.
* refactor(channels): use crossbeam instead of mpsc
This patch replaces mpsc with crossbeam channels because crossbeam
supports selecting on multiple channels which will be necessary in a
subsequent patch.
* refactor(threadbus): allow multiple receivers in Bus
This patch changes Bus to use multiple receivers. Method `recv` returns
data from all of them. This will be used in a subsequent patch for
receiving from bounded and unbounded queues at the same time.
* refactor(channels): remove SenderType enum
This enum has only one variant, so the entire enum can be replaced with
the innards of said variant.
* refactor(channels): remove Send+Sync trait implementations
The implementation of these traits is not necessary, as
SenderWithContext is automatically Send and Sync for every T and
ErrorContext that's Send and Sync.
* refactor(os_input_output): use Pid for child process
* fix(debug): change debug_to_file to write &[u8]
This patch changes debug_to_file to write entire slices in one call, to
avoid the overhead of opening and closing files for each byte written.
* refactor(ServerOsApi): remove unnecessary muts from methods
Co-authored-by: KOVACS Tamas <ktamas@fastmail.fm>
* The setup subcommand was exiting the programm no matter what
even if the `clean` flag was provided.
Now it returns to the
main function on encountering the clean flag.
* changed `enable_automatic_asset_installation` to
`disable_automatic_asset_installation`
This ensures that people by default get the
asset installation and need to opt out at
compile time, rather than opt in.
* removed default features
Not needed anymore.
* The check option communicates default and config options to the user
as well as optional compile time features
* Move generate-completion from a subcommand to a flag in the setup
subcommand
closes#380
* --features disable_automatic_asset_installation
disables automatic installation of the `data_dir`
* a set PREFIX env will use `$PREFIX/zellij` as its `data_dir`