-
Notifications
You must be signed in to change notification settings - Fork 274
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
EventStream
spawns a new thread on every event
#448
Comments
Actually, investigating further it seems this may be intended behaviour after all? // Stream::poll_next can return Poll::Pending which means that there's no
// event available. We are going to spawn a thread with the
// poll_internal(None, &EventFilter) call. This call blocks until an
// event is available and then we have to wake up the executor with notification
// that the task can be resumed. Is there no way to avoid this? It seems terribly inefficient. I am thinking that at least conceptually,
// I apologize in advance if this reads like the ramblings of a madman :-) -- I'm new to the codebase -- I'm migrating over from supporting multiple backends to just crossterm because of its much nicer input story (e.g. |
Describe the bug
Using
EventStream
seems to spawn a new thread on every event.To Reproduce
The behaviour can be reproduced with the
event-stream-tokio.rs
example. Notice the new PID inhtop
in the gif below which changes on every keypress.How to reproduce [gif]
N.B. In the gif above,
core_threads
is set to one for clarity (i.e.#[tokio::main(core_threads = 1)]
).Expected behavior
A new thread should not be created on every keystroke.
OS
Ubuntu 20.04 LTS (Linux 5.4.0-37-generic x86_64)
Terminal/Console
Alacritty + tmux.
After investigating this, I thought it may be related to
tput
because of the following comment in the source codeHowever, this doesn't seem to be the case -- the branch where tput gets called (when
/dev/tty
is not available) is not taken and at any rate removing the signal handling logic forsignal_hook::SIGWINCH
doesn't change the behaviour.The text was updated successfully, but these errors were encountered: