[Rpm-maint] [rpm-software-management/rpm] Use close_range() to set close-on-exec on all fds (PR #4149)

Alberto Ruiz notifications at github.com
Sat Mar 14 03:16:54 UTC 2026


rpmSetCloseOnExec() iterates over every open fd and calls fcntl() twice per fd to set FD_CLOEXEC. Profiling a 'dnf install systemd' transaction shows this accounts for ~19% of total CPU time, called hundreds of times (once per scriptlet and file trigger invocation).

Use close_range(3, ~0U, CLOSE_RANGE_CLOEXEC) when available (Linux 5.11+, glibc 2.34+) to do this in a single syscall, falling back to the existing per-fd loop on older systems.

Benchmarks show ~26% performance improvement in time spent doing an rpm install.
You can view, comment on, or merge this pull request online at:

  https://github.com/rpm-software-management/rpm/pull/4149

-- Commit Summary --

  * Use close_range() to set close-on-exec on all fds

-- File Changes --

    M CMakeLists.txt (2)
    M config.h.in (1)
    M rpmio/rpmio.cc (5)

-- Patch Links --

https://github.com/rpm-software-management/rpm/pull/4149.patch
https://github.com/rpm-software-management/rpm/pull/4149.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/4149
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/4149 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20260313/f9f4a97f/attachment.htm>


More information about the Rpm-maint mailing list