-
Notifications
You must be signed in to change notification settings - Fork 287
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
Use select()
instead of mio
polling in Unix EventSource
#711
Conversation
src/event/source/unix.rs
Outdated
// once more data is available to read. | ||
io::ErrorKind::WouldBlock => break, | ||
io::ErrorKind::Interrupted => continue, | ||
_ => return Err(e), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch was missing, I believe it was a mistake, but this could be a behavior change
So unfortunately this solution is partial and will only work with fds < 1024. There is a workaround for Darwin, I'm working on implementing it , but it won't be pretty. And it would mean using |
Thanks for filing the PR and contributing to crossterm!
What does this imply?
If the potential workaround is a dirty one, I would argue to stay with mio, and hope macOS supports tty in kqueue (which seems to be the issue). Tho if you argue the workaround outweighs the benefits of switching to poll, please provide the arguments why you think so, and then we can consider continuing the work here. |
Hey @TimonPost , I'll try to summarize the situation as best I can. As you said, the core issue is that So the idea behind this PR was to switch both the Linux and macOS implementations to use
The implication of this limitation is that apps that open more than 1024 files will not be able to use the event stream after those files have been opened, since (In MacOS, there is a way to work around this limitation by compiling with different compile-time flags, which causes a different version of In short, we are left with the following options as I can tell:
I'm willing to put in the work, just give me the go ahead on what you think is the best choice. I am leaning towards option 2, however there might be something I'm missing. Cheers |
I like solution 2, lets go for that.
Perhaps, we could do a smooth transition by just creating a new event source as you did, and exposing it behind a feature flag. Just needs good manual testing on various platforms if we are going to do the polling our selves. Atm, I only have windows, but soon, I will possess a MacBook. Linux for me is only accessible through wsl 2. What platforms can you test on? We just have to be sure our custom implementation works well enough and doesnt introduce more bugs then it tries to solve. I im a bit worried of knowing the nature of Linux terminal and differences per OS. |
I'm trying to use crossterm in my tui app and this is a blocker for me, so I'm happy to help test. I have access to Linux and Mac environments |
@TimonPost Sounds good to me, I'll get started then. I have all three platforms available to test on. @conradludgate you can use this branch in the meantime, see helix-editor/helix#2111 (comment) |
I already am in testing. It works great for me right now (using select). I won't merge it like this though |
Also my personal opinion is to use select for macos without the hack. I think as a fist cut that would be a nice step and the limitation seems theoretical. We can improve things when it gets tested in real world and people complain. |
@sigmaSd this is still a draft, but I recently found filedescriptor's poll, which is used in |
opened #735 |
I've run into #500 (which is caused by tokio-rs/mio#1377) several times now, so here is a shot at reimplementing
EventSource
usingselect()
instead ofmio
as discussed in the issue. I tested it a bit and it seems to work fine, but let me know if there's anything specific you want me to test.I thought about using
nix
but decided against adding another dependency since usinglibc::select()
is pretty straightforward.Fixes #500, unblocks #407