Skip to content
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 rustix instead of nix? #733

Open
newpavlov opened this issue Sep 22, 2023 · 10 comments
Open

Use rustix instead of nix? #733

newpavlov opened this issue Sep 22, 2023 · 10 comments

Comments

@newpavlov
Copy link

Both crates are quite similar to each other, but rusyline already pulls rustix via fd-lock. Thus migrating to rustix would make dependency tree of rustyline smaller. Additionally, rustix is developed a bit more actively and provides the nice linux_raw backend feature (i.e. much less errno stupidity).

@gwenn
Copy link
Collaborator

gwenn commented Oct 1, 2023

rustix doesn't seem to support select

@newpavlov
Copy link
Author

Per select documentation:

All modern applications should instead use poll(2) or epoll(7)

Is there a reason why rustyline can not use one of those?

@gwenn
Copy link
Collaborator

gwenn commented Oct 1, 2023

@newpavlov
Copy link
Author

I think migration to rustix should be a good opportunity to remove dependence on select then, no?

@gwenn
Copy link
Collaborator

gwenn commented Oct 2, 2023

@newpavlov
Copy link
Author

newpavlov commented Oct 2, 2023

Do you want to say that because rustix is not on that (unofficial) list it's inferior to nix?

rustix is developed more actively, has a member of the rust-lang org in the list of maintainers, has the desirable linux_raw feature, and has almost twice more in the number of recent downloads than nix. The only "disadvantage" is that rustix, being a fork of nix, is a younger crate.

@gwenn
Copy link
Collaborator

gwenn commented Oct 7, 2023

Thus migrating to rustix would make dependency tree of rustyline smaller

Wrong:

rustyline % cargo tree --no-default-features
├── nix v0.27.1
│   ├── bitflags v2.4.0
│   ├── cfg-if v1.0.0
│   └── libc v0.2.148

vs

rustyline % cargo tree --features with-file-history
│   └── rustix v0.38.17
│       ├── bitflags v2.4.0
│       ├── errno v0.3.4
│       │   └── libc v0.2.148
│       └── libc v0.2.148

=> one more dependency: errno

@newpavlov
Copy link
Author

As mentioned in the OP, most users pull rustix through fd-lock since with-file-history is a default feature.

Sigh... If you do not want to migrate to rustix, just say so and close this issue. I personally will not be happy about it, since in my project only rustyline pulls nix, while rustix is pulled by several other dependencies, but it's your crate and your decision. I can deal with it on my side either by leaving everything as-is or by eventually migrating to an alternative.

@bkaestner
Copy link

rustix doesn't seem to support select

If I get it correctly, then rustyline still uses select(2) internally? This will lead to panics at runtime on any application that have a file descriptor greater than FD_SETSIZE (see also nix-rust/nix#1087).

FD_SETSIZE can be reached quite quickly when using sockets and threads, so please consider switching to nix::poll::poll instead. As someone who has been recently bitten in the arse by cross-language usage of select(2), I would be happy to provide a patch that replaces the nix::select::select call by nix::poll:poll.

@gwenn
Copy link
Collaborator

gwenn commented Sep 8, 2024

Just for your information, select seems to be mandatory on MacOS:
See #802

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants