In case maximum number of open files limit is set too high, Pexec() spends way 
too much time trying to set FD_CLOEXEC for all those file descriptors, 
resulting in severe increase of time it takes to execute rpm or dnf. For 
example, this happens while running under Docker because:

> $ docker run fedora ulimit -n
> 1048576

One obvious fix is when open_max is too big, use procfs to get the actual list 
of opened file descriptors and iterate over those.

My quick-n-dirty benchmark shows the /proc approach is about 10x faster than 
iterating through a list of 1024 fds.

Note that this commit is rather conservative, meaning that the old code is used:
 - if open_max <= 1024;
 - if /proc is not available.

This should fix:
- https://github.com/moby/moby/issues/23137
- https://bugzilla.redhat.com/show_bug.cgi?id=1537564
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * luaext/Pexec: optimize setting CLOEXEC

-- File Changes --

    M luaext/lposix.c (60)

-- Patch Links --

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

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/444
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to