[libvirt] [PATCH 0/3] Optimize mass closing of FDs on child spwaning

Daniel P. Berrangé berrange at redhat.com
Wed Jul 3 08:44:41 UTC 2019


On Wed, Jul 03, 2019 at 09:19:17AM +0200, Michal Privoznik wrote:
> If the limit for max opened files is way bigger than the default (1024),
> say 3 orders bigger then spawning a child through virCommand can be
> expensive because we iterate over ALL FDs within the limit and close
> them. There's no need to that since we can learn the list of opened FDs
> from /proc/self/fd/.

Yeah I've seen this in docker containers in particular where the
nfiles limit is something like 2 million.

Hopefully Linux will finally get something equiv to BSD's closefrom()
syscall we can use in the future:

  https://lwn.net/Articles/593778/

meanwhile relying on /proc is reasonable I guess. The extra syscalls
to read the dir should be balanced by fewer close syscalls quite
easily.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list