Subject: libvirtd daemon scans /gnu/store for unknown reasons, uses 600 MiB of RSS memory

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 09 Apr 2024 17:07:05 -0400

Hi,

I've discovered that libvirtd on my Guix System consumes an excessive
amount of resident memory, about 600 MiB.  Other GNU/Linux users report
their daemon uses about 20 MiB.  This is when no virtual machine is in
use.

Attaching strace to a freshly started libvirtd process, we can observe
the following strace output:

--8<---------------cut here---------------start------------->8---
$ sudo strace -vf -s600 -p$(pgrep libvirtd)

[pid  4355] read(23, "", 7292)          = 0
[pid  4355] close(23)                   = 0
[pid  4355] newfstatat(AT_FDCWD, "/gnu/store/pyw31df87mwlxjgi8q9bsbj9725cd2vz-rustc-1.69.0-src.tar.xz-builder", {st_dev=makedev(0, 0x18), st_ino=341758129, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=3880, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.196626584-0400 */, st_ctime_nsec=196626584}, AT_SYMLINK_NOFOLLOW) = 0
[pid  4355] openat(AT_FDCWD, "/gnu/store/pyw31df87mwlxjgi8q9bsbj9725cd2vz-rustc-1.69.0-src.tar.xz-builder", O_RDONLY|O_NOCTTY|O_NONBLOCK) = 23
[pid  4355] newfstatat(23, "", {st_dev=makedev(0, 0x18), st_ino=341758129, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=3880, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.196626584-0400 */, st_ctime_nsec=196626584}, AT_EMPTY_PATH) = 0
[pid  4355] fcntl(23, F_GETFL)          = 0x8800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE)
[pid  4355] fcntl(23, F_SETFL, O_RDONLY|O_LARGEFILE) = 0
[pid  4355] newfstatat(23, "", {st_dev=makedev(0, 0x18), st_ino=341758129, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=3880, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.196626584-0400 */, st_ctime_nsec=196626584}, AT_EMPTY_PATH) = 0
[pid  4355] lseek(23, 0, SEEK_SET)      = 0
[pid  4355] read(23, "(begin (use-modules (ice-9 ftw) (ice-9 match) (ice-9 regex) (srfi srfi-1) (srfi srfi-26) (guix build utils)) (define tar-supports-sort? (zero? (system* (string-append \"/gnu/store/8n53xwg5yzm5wzv9c9gcn6rjmq975k06-tar-1.34\" \"/bin/tar\") \"cf\" \"/dev/null\" \"--files-from=/dev/null\" \"--sort=name\"))) (define (apply-patch patch) (format (current-error-port) \"applying '~a'...~%\" patch) (invoke (string-append \"/gnu/store/d9838iax3lgm57glvv43a1pwpnaipljw-patch-2.7.6\" \"/bin/patch\") \"--force\" \"--no-backup-if-mismatch\" \"-p1\" \"--input\" patch)) (define (first-file directory) (car (scandir directory (lambda (nam"..., 8192) = 3880
[pid  4355] read(23, "", 4312)          = 0
[pid  4355] close(23)                   = 0
[pid  4355] newfstatat(AT_FDCWD, "/gnu/store/fdk9wcp5idm4vgcz0ysps3qvrf7545a3-rustc-1.69.0-src.tar.xz.drv", {st_dev=makedev(0, 0x18), st_ino=341758131, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=1290, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.196626584-0400 */, st_ctime_nsec=196626584}, AT_SYMLINK_NOFOLLOW) = 0
[pid  4355] openat(AT_FDCWD, "/gnu/store/fdk9wcp5idm4vgcz0ysps3qvrf7545a3-rustc-1.69.0-src.tar.xz.drv", O_RDONLY|O_NOCTTY|O_NONBLOCK) = 23
[pid  4355] newfstatat(23, "", {st_dev=makedev(0, 0x18), st_ino=341758131, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=1290, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.196626584-0400 */, st_ctime_nsec=196626584}, AT_EMPTY_PATH) = 0
[pid  4355] fcntl(23, F_GETFL)          = 0x8800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE)
[pid  4355] fcntl(23, F_SETFL, O_RDONLY|O_LARGEFILE) = 0
[pid  4355] newfstatat(23, "", {st_dev=makedev(0, 0x18), st_ino=341758131, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=1290, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.196626584-0400 */, st_ctime_nsec=196626584}, AT_EMPTY_PATH) = 0
[pid  4355] lseek(23, 0, SEEK_SET)      = 0
[pid  4355] read(23, "Derive([(\"out\",\"/gnu/store/9y2dsnwcdm2a3chmasqkg0wha057cg8g-rustc-1.69.0-src.tar.xz\",\"\",\"\")],[(\"/gnu/store/5kxy5mynf2msxwg3diggsgfi9089cl81-rustc-1.69.0-src.tar.gz.drv\",[\"out\"]),(\"/gnu/store/6i2qvlvfmhmw2vsf8x5jqxsgbpd9kx9p-glibc-utf8-locales-2.35.drv\",[\"out\"]),(\"/gnu/store/782cqklvsgj1fqx27z8mwlyfzcsp8zf6-tar-1.34.drv\",[\"out\"]),(\"/gnu/store/chfm45pzy6ns8acijzdybc0w9fyjwqk7-module-import-compiled.drv\",[\"out\"]),(\"/gnu/store/kjl3hb157z9pn0hc8pllvqx5likddbwd-xz-5.2.8.drv\",[\"out\"]),(\"/gnu/store/qhprma6ljxd7gahjhf0zibg1h55scil1-patch-2.7.6.drv\",[\"out\"]),(\"/gnu/store/rilznn39py809ipysvmd0gz7n10s9m11"..., 8192) = 1290
[pid  4355] read(23, "", 6902)          = 0
[pid  4355] close(23)                   = 0
[pid  4355] newfstatat(AT_FDCWD, "/gnu/store/adsc0x3545c3giv12z1xlgr7y9jzi6bz-rust-1.69.0-builder", {st_dev=makedev(0, 0x18), st_ino=341758133, st_mode=S_IFREG|0444, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=24, st_size=8537, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.200626460-0400 */, st_ctime_nsec=200626460}, AT_SYMLINK_NOFOLLOW) = 0
[pid  4355] openat(AT_FDCWD, "/gnu/store/adsc0x3545c3giv12z1xlgr7y9jzi6bz-rust-1.69.0-builder", O_RDONLY|O_NOCTTY|O_NONBLOCK) = 23
[pid  4355] newfstatat(23, "", {st_dev=makedev(0, 0x18), st_ino=341758133, st_mode=S_IFREG|0444, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=24, st_size=8537, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.200626460-0400 */, st_ctime_nsec=200626460}, AT_EMPTY_PATH) = 0
[pid  4355] fcntl(23, F_GETFL)          = 0x8800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE)
[pid  4355] fcntl(23, F_SETFL, O_RDONLY|O_LARGEFILE) = 0
[pid  4355] newfstatat(23, "", {st_dev=makedev(0, 0x18), st_ino=341758133, st_mode=S_IFREG|0444, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=24, st_size=8537, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.200626460-0400 */, st_ctime_nsec=200626460}, AT_EMPTY_PATH) = 0
[pid  4355] lseek(23, 0, SEEK_SET)      = 0
[pid  4355] read(23, "(begin (use-modules (guix build cargo-utils) (guix build utils) (guix build gnu-build-system) (ice-9 match) (srfi srfi-1)) (begin (define %build-inputs (quote ((\"source\" . \"/gnu/store/9y2dsnwcdm2a3chmasqkg0wha057cg8g-rustc-1.69.0-src.tar.xz\") (\"cmake\" . \"/gnu/store/h6j5knfc7miynfhfrf1gkyvn0559vszc-cmake-minimal-3.24.2\") (\"pkg-config\" . \"/gnu/store/kg6v5r1w8xrkwq9yclpcjh0cjv980wa0-pkg-config-0.29.2\") (\"python\" . \"/gnu/store/yhp1alq433bi1j32zchsxg54fmcc79bw-python-wrapper-3.10.7\") (\"rustc-bootstrap\" . \"/gnu/store/kpg9is51838642qk546m5s35wkr3w77g-rust-1.68.2\") (\"cargo-bootstrap\" . \"/gnu/store/b8x"..., 8192) = 8192
[pid  4355] mprotect(0x7fb9eddeb000, 12288, PROT_READ|PROT_WRITE) = 0
[pid  4355] read(23, "opy[Rr]ight(\\\\.(txt|md))?)$\" #:strip-binaries? #t #:validate-runpath? #t #:make-dynamic-linker-cache? #t #:license-file-regexp \"^(COPYING.*|LICEN[CS]E.*|[Ll]icen[cs]e.*|Copy[Rr]ight(\\\\.(txt|md))?)$\" #:strip-flags (quote (\"--strip-unneeded\" \"--enable-deterministic-archives\")) #:strip-directories (quote (\"lib\" \"lib64\" \"libexec\" \"bin\" \"sbin\")))))", 8192) = 345
[pid  4355] read(23, "", 7847)          = 0
[pid  4355] close(23)                   = 0
[pid  4355] newfstatat(AT_FDCWD, "/gnu/store/s53vgqzdhg20cfx7i8q9gnjajac5fhfz-rust-1.69.0.drv", {st_dev=makedev(0, 0x18), st_ino=341758135, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=3519, st_atime=1698766945 /* 2023-10-31T11:42:25-0400 */, st_atime_nsec=0, st_mtime=1 /* 1969-12-31T19:00:01-0500 */, st_mtime_nsec=0, st_ctime=1698766945 /* 2023-10-31T11:42:25.204626336-0400 */, st_ctime_nsec=204626336}, AT_SYMLINK_NOFOLLOW) = 0
--8<---------------cut here---------------end--------------->8---

I suspect that this walking of /gnu/store has something to do with the
high memory usage of libvirtd.

-- 
Thanks,
Maxim