GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-38061: subprocess uses closefrom() on FreeBSD by vstinner · Pull Request #19697 · python/cpython

bpo-38061: subprocess uses closefrom() on FreeBSD #19697

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.

Sign up for GitHub

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

Merged
vstinner merged 1 commit into python:master from vstinner:subprocess_closefrom
Apr 24, 2020

Uh oh!

There was an error while loading. Please reload this page.

Merged

bpo-38061: subprocess uses closefrom() on FreeBSD #19697

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
0c8b6d8
bpo-38061: subprocess uses closefrom() on FreeBSD
vstinner Apr 23, 2020
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

4 changes: 4 additions & 0 deletions 4 Doc/whatsnew/3.9.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,10 @@ Optimizations
until the main thread handles signals.
(Contributed by Victor Stinner in :issue:`40010`.)

* Optimize the :mod:`subprocess` module on FreeBSD using ``closefrom()``.
(Contributed by Ed Maste, Conrad Meyer, Kyle Evans, Kubilay Kocak and Victor
Stinner in :issue:`38061`.)


Build and C API Changes
=======================
Expand Down
11 changes: 11 additions & 0 deletions 11 Misc/NEWS.d/next/Library/2020-04-24-01-55-00.bpo-38061.XmULB3.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Optimize the :mod:`subprocess` module on FreeBSD using ``closefrom()``.
A single ``close(fd)`` syscall is cheap, but when ``sysconf(_SC_OPEN_MAX)`` is
high, the loop calling ``close(fd)`` on each file descriptor can take several
milliseconds.

The workaround on FreeBSD to improve performance was to load and mount the
fdescfs kernel module, but this is not enabled by default.

Initial patch by Ed Maste (emaste), Conrad Meyer (cem), Kyle Evans (kevans) and
Kubilay Kocak (koobs):
Comment thread

@koobs koobs Apr 24, 2020

Copy link
Copy Markdown

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.

Can remove this, full credit to Ed, Conrad & Kyle

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Apr 24, 2020

Copy link
Copy Markdown
Member Author

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.

Even if you didn't write the patch directly, you helped to get it packaged. Thanks @koobs, you deserved to be credited ;-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242274
8 changes: 7 additions & 1 deletion 8 Modules/_posixsubprocess.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,15 @@ _close_fds_by_brute_force(long start_fd, PyObject *py_fds_to_keep)
start_fd = keep_fd + 1;
}
if (start_fd <= end_fd) {
#if defined(__FreeBSD__)
/* Any errors encountered while closing file descriptors are ignored */
closefrom(start_fd);
#else
for (fd_num = start_fd; fd_num < end_fd; ++fd_num) {
close(fd_num);
/* Ignore errors */
(void)close(fd_num);
}
#endif
}
}

Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.