-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 fcntl(fd, F_GETFD)
to detect if standard streams are open
#96837
Conversation
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
(rust-highfive has picked a reviewer for you, use r? to override) |
LGTM. @bors r+ |
📌 Commit ba84ead159472666303de68104dce86ddc9b815c has been approved by |
This costs 2 more syscalls at program startup, which adds up to a few microseconds I guess? Not the end of the world but still slower than the previous implementation. |
@the8472 I would be happy to merge a version that tries In this context, I felt like it made sense to merge the new test and the code to make that test pass. A subsequent PR can add the fast-path and ensure the test still passes. |
⌛ Testing commit ba84ead159472666303de68104dce86ddc9b815c with merge 23bc2980951e5f1056dbb81d60e8478833cd1e48... |
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
In the previous implementation, if the standard streams were open, but the RLIMIT_NOFILE value was below three, the poll would fail with EINVAL: > ERRORS: EINVAL The nfds value exceeds the RLIMIT_NOFILE value. Switch to the existing fcntl based implementation to avoid the issue.
|
@bors r+ |
📌 Commit e0a53ed has been approved by |
@bors r- |
This was discussed this in today's libs meeting. To keep the amount of unavoidable syscalls at program startup small we'd prefer to keep in the poll as fast path and only fall back to fcntl when it returns the error indicating that the rlimit was hit. Since this PR mostly removes code it wouldn't make much sense to add it back with different control flow in a separate PR. |
I have done the changes and pushed them to tmiasko's branch. |
this minimizes the amount of syscalls performed during startup
@bors r+ |
📌 Commit 4ae6f9fd98f4db113241711b11278cd27746036d has been approved by |
@bors r- |
Converted the ifs to a match, I assume that's trivial enough that it won't need another review. @bors r=joshtriplett |
📌 Commit 2e62fda has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (ec55c61): comparison url. Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results
CyclesResults
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression Footnotes |
The test added in this PR now forces to install |
In the previous implementation, if the standard streams were open,
but the RLIMIT_NOFILE value was below three, the poll would fail
with EINVAL:
Switch to the existing fcntl based implementation to avoid the issue.
Fixes #96621.