Skip to content
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.

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

nixos-rebuild --switch too slow, tracking issue #57477

Open
infinisil opened this issue Mar 12, 2019 · 23 comments
Open

nixos-rebuild --switch too slow, tracking issue #57477

infinisil opened this issue Mar 12, 2019 · 23 comments
Labels
5. scope: tracking Long-lived issue tracking long-term fixes or multiple sub-problems 6.topic: module system About "NixOS" module system internals 6.topic: nixos

Comments

@infinisil
Copy link
Member

infinisil commented Mar 12, 2019

I'm opening this issue to track some things I've done relating to the continuous slowdown of nixos evaluation performance over time.

My system takes 13 seconds to evaluate (nix-instantiate '<nixpkgs/nixos>' -A system), which is too long!

What I've done

Measurements

commit (release): instantiation time for demo.nix (time nix-instantiate test.nix -A system, number of options (cat $(nix-build --no-out-link nixos/release.nix -A options)/share/doc/nixos/options.json | jq 'keys[]' -r | wc -l), number of modules (nix-instantiate --eval -E 'builtins.length (import nixos/modules/module-list.nix)')

a6caed5 (19.03): 2.74, 7630, 887
37694c8 (18.09): 2.40, 6937, 831
c8c521f (18.03): 2.25, 6280, 772
3ba3d8d (17.09): 1.62, 5741, 737
2c1838a (17.03): 1.22, 5114, 669
52ef8b0 (16.09): 0.73, 4234, 590
dda40aa (16.03): 0.65, 3624, 535
cc7c261 (15.09): 0.62, 3131, 493
7708224 (14.12): 0.60, 2451, 407

module count has increased by 118%
option count has increased by 211%
average option count per module has increased from 6.0 to 8.6
time has increased by 356%

Turning off the options manual generation

I was hoping that the reason for the regression is due to all options being evaluated strictly, so here's my branch (probably could've just turned off the manual but oh well). Results: Decreases evaluation time by a constant of ~1 second, so my system now only takes 12 seconds.. Not good enough. See branch for a bit more info.

Alternatively, earlier, offloading option generation to build time

Branch here. Results: Mostly failed, recursive Nix doesn't work very well and it brings a lot of limitations with it. See branch for a bit more info.

Theory / Conclusion

Being out of time for now, I feel like the problem is a combination of:

  • The enable options (and similar ones). These enable options are defined for every module and they need to be evaluated regardless of whether you use the module or not, so this adds up with the ~1110 enable options we have in 19.03, and ever increasing
  • The module files itself. This ever increasing list of modules to include by default means that Nix needs to parse and evaluate all of them, which of course takes an increasing amount of time.

So this would also mean that the number of options a module defines has only very little influence on evaluation time (in contrast to what I've thought and told other people for some time now)! Of course the manual penalty of 1s is still there, but that's almost negligible.

Future Work

  • Do some proper profiling with NIX_COUNT_CALLS=1 and/or NIX_SHOW_STATS=1
  • Set up an automated way to track evaluation time for NixOS evaluation (maybe that already exists?)
  • Now that we have the better cross compilation, how much worse is the performance due to that?

Related

Pings

@edolstra @nbp @Profpatsch @rycee @aanderse @Ekleog @Ericson2314

@edolstra
Copy link
Member

See also NixOS/rfcs#22.

@Ekleog Ekleog mentioned this issue Mar 12, 2019
10 tasks
@asymmetric
Copy link
Contributor

Results: Increases evaluation time by a constant of ~1 second

@infinisil I think you mean "decreases"?

@Profpatsch
Copy link
Member

Profpatsch commented Mar 13, 2019

Another (general) approach to debugging evaluation times would be to add a flamegraph output to nix itself. Because apart from very simple counters we have no way to debug the evaluation as far as I’m aware of.

The bazel build system has an option to debug their evaluator by outputting the flamegraph format that can be read by the Chromium devtools (and so probably also firebug). We should add the same.

@infinisil
Copy link
Member Author

I just wrote a little script to minimize module-list.nix by removing everything that wasn't necessary:

for i in $(seq $(( $(cat module-list.nix | wc -l) - 1 )) -1 2); do
  echo $i
  if nix-instantiate ../lib/eval-config.nix --arg system 'builtins.currentSystem' --arg modules '[ ./configuration.nix ]' --arg baseModules "$(cat module-list.nix | sed ${i}d)" -A config.system.build.toplevel; then
    sed -i ${i}d module-list.nix
  fi
done

I put a minimal configuration.nix in ~/src/nixpkgs/nixos/modules

{
  boot.loader.grub.device = "nodev";
  fileSystems."/".device = "x";
}

Then

$ cd ~/src/nixpkgs/nixos/modules
$ ./minimize-modules
$ ./minimize-modules

I needed two runs because of module dependencies from earlier to later modules in the list.

The resulting module-list.nix consists of only 154 out of the original 890 modules:

[
  ./config/xdg/autostart.nix
  ./config/xdg/icons.nix
  ./config/xdg/menus.nix
  ./config/xdg/mime.nix
  ./config/i18n.nix
  ./config/krb5/default.nix
  ./config/ldap.nix
  ./config/networking.nix
  ./config/nsswitch.nix
  ./config/power-management.nix
  ./config/pulseaudio.nix
  ./config/shells-environment.nix
  ./config/swap.nix
  ./config/sysctl.nix
  ./config/system-environment.nix
  ./config/system-path.nix
  ./config/users-groups.nix
  ./hardware/all-firmware.nix
  ./hardware/ckb-next.nix
  ./i18n/input-method/default.nix
  ./i18n/input-method/ibus.nix
  ./misc/assertions.nix
  ./misc/documentation.nix
  ./misc/extra-arguments.nix
  ./misc/ids.nix
  ./misc/lib.nix
  ./misc/label.nix
  ./misc/meta.nix
  ./misc/nixpkgs.nix
  ./misc/version.nix
  ./programs/bash/bash.nix
  ./programs/shadow.nix
  ./programs/ssh.nix
  ./programs/zsh/oh-my-zsh.nix
  ./programs/zsh/zsh.nix
  ./programs/zsh/zsh-autosuggestions.nix
  ./programs/zsh/zsh-syntax-highlighting.nix
  ./rename.nix
  ./security/acme.nix
  ./security/chromium-suid-sandbox.nix
  ./security/google_oslogin.nix
  ./security/oath.nix
  ./security/pam.nix
  ./security/pam_usb.nix
  ./security/pam_mount.nix
  ./security/polkit.nix
  ./security/rtkit.nix
  ./security/wrappers/default.nix
  ./security/sudo.nix
  ./services/cluster/kubernetes/addons/dns.nix
  ./services/cluster/kubernetes/addon-manager.nix
  ./services/cluster/kubernetes/apiserver.nix
  ./services/cluster/kubernetes/controller-manager.nix
  ./services/cluster/kubernetes/default.nix
  ./services/cluster/kubernetes/flannel.nix
  ./services/cluster/kubernetes/kubelet.nix
  ./services/cluster/kubernetes/pki.nix
  ./services/cluster/kubernetes/proxy.nix
  ./services/cluster/kubernetes/scheduler.nix
  ./services/databases/mysql.nix
  ./services/desktops/accountsservice.nix
  ./services/desktops/bamf.nix
  ./services/desktops/dleyna-renderer.nix
  ./services/desktops/dleyna-server.nix
  ./services/desktops/pantheon/contractor.nix
  ./services/desktops/pantheon/files.nix
  ./services/desktops/flatpak.nix
  ./services/desktops/geoclue2.nix
  ./services/desktops/gsignond.nix
  ./services/desktops/gnome3/at-spi2-core.nix
  ./services/desktops/gnome3/evolution-data-server.nix
  ./services/desktops/gnome3/file-roller.nix
  ./services/desktops/gnome3/gnome-disks.nix
  ./services/desktops/gnome3/gnome-documents.nix
  ./services/desktops/gnome3/gnome-keyring.nix
  ./services/desktops/gnome3/gnome-online-accounts.nix
  ./services/desktops/gnome3/gnome-remote-desktop.nix
  ./services/desktops/gnome3/gnome-online-miners.nix
  ./services/desktops/gnome3/gnome-terminal-server.nix
  ./services/desktops/gnome3/gnome-user-share.nix
  ./services/desktops/gnome3/gvfs.nix
  ./services/desktops/gnome3/rygel.nix
  ./services/desktops/gnome3/seahorse.nix
  ./services/desktops/gnome3/sushi.nix
  ./services/desktops/gnome3/tracker.nix
  ./services/desktops/gnome3/tracker-miners.nix
  ./services/desktops/telepathy.nix
  ./services/desktops/tumbler.nix
  ./services/desktops/zeitgeist.nix
  ./services/hardware/bluetooth.nix
  ./services/hardware/bolt.nix
  ./services/hardware/udev.nix
  ./services/hardware/udisks2.nix
  ./services/hardware/upower.nix
  ./services/logging/rsyslogd.nix
  ./services/logging/syslog-ng.nix
  ./services/mail/postgrey.nix
  ./services/misc/etcd.nix
  ./services/misc/nix-daemon.nix
  ./services/misc/nixos-manual.nix
  ./services/misc/packagekit.nix
  ./services/misc/sssd.nix
  ./services/network-filesystems/samba.nix
  ./services/networking/avahi-daemon.nix
  ./services/networking/bind.nix
  ./services/networking/ddclient.nix
  ./services/networking/dhcpcd.nix
  ./services/networking/dhcpd.nix
  ./services/networking/dnsmasq.nix
  ./services/networking/firewall.nix
  ./services/networking/flannel.nix
  ./services/networking/iodine.nix
  ./services/networking/mstpd.nix
  ./services/networking/networkmanager.nix
  ./services/networking/racoon.nix
  ./services/networking/ssh/sshd.nix
  ./services/networking/unbound.nix
  ./services/networking/wpa_supplicant.nix
  ./services/printing/cupsd.nix
  ./services/security/certmgr.nix
  ./services/security/cfssl.nix
  ./services/security/fprintd.nix
  ./services/system/dbus.nix
  ./services/system/nscd.nix
  ./services/ttys/agetty.nix
  ./services/web-apps/matomo.nix
  ./services/web-servers/nginx/default.nix
  ./services/x11/colord.nix
  ./services/x11/hardware/libinput.nix
  ./services/x11/gdk-pixbuf.nix
  ./services/x11/xserver.nix
  ./system/activation/activation-script.nix
  ./system/activation/top-level.nix
  ./system/boot/grow-partition.nix
  ./system/boot/kernel.nix
  ./system/boot/loader/efi.nix
  ./system/boot/loader/grub/grub.nix
  ./system/boot/loader/loader.nix
  ./system/boot/modprobe.nix
  ./system/boot/resolved.nix
  ./system/boot/stage-1.nix
  ./system/boot/stage-2.nix
  ./system/boot/systemd.nix
  ./system/etc/etc.nix
  ./tasks/filesystems.nix
  ./tasks/kbd.nix
  ./tasks/network-interfaces.nix
  ./virtualisation/containers.nix
  ./virtualisation/docker.nix
  ./virtualisation/lxcfs.nix
  ./virtualisation/openvswitch.nix
  ./virtualisation/virtualbox-guest.nix
  ./virtualisation/virtualbox-host.nix
  ./virtualisation/vmware-guest.nix
]

Evaluation time for this (trivial) configuration.nix went down from ~1.9 to ~0.9 seconds:

$ time nix-instantiate ../lib/eval-config.nix --arg system 'builtins.currentSystem' --arg modules '[ ./configuration.nix ]' --arg baseModules 'import ./original-module-list.nix' -A config.system.build.toplevel
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/7zxpkl6ayw45bf3xf6l3cd5pxzb7zg6q-nixos-system-nixos-19.03.git.42bf842.drv
1.59s user 0.17s system 94% cpu 1.854 total
$ time nix-instantiate ../lib/eval-config.nix --arg system 'builtins.currentSystem' --arg modules '[ ./configuration.nix ]' --arg baseModules 'import ./module-list.nix' -A config.system.build.toplevel
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/2sylcv6g034jw4r36qywbnpxq7zkf0f3-nixos-system-nixos-19.03.git.42bf842.drv
0.69s user 0.10s system 90% cpu 0.868 total

Todo: Repeat for real configuration.nixs

@memberbetty
Copy link
Contributor

Does Guix also suffer from this?

Has anyone done benchmarking on Guix vs Nix? I am still using Nix exclusively, but there are costs to a new language ecosystem (lack of tooling). Using an existing interpreter and language is from a maintenance perspective appealing.

@danbst
Copy link
Contributor

danbst commented Dec 23, 2019

If nix-instantiate is slow for your system, maybe nixos-rebuild switch --fast can help here, as it removes extra module evaluation.

Also, it may be that switching nixos-rebuild to Nix 2 can speedup in build-phase (where many small files are built). At least it doesn't block on stdout buffering.

@infinisil
Copy link
Member Author

@danbst --fast seems to only turn off building Nix before the actual system build, which nix-instantiate doesn't do already anyways. In this issue I'm also mainly focusing on evaluation time, since build time varies depending on what you already have built, whereas evaluation time is constant, even for no changes at all.

@danbst
Copy link
Contributor

danbst commented Dec 24, 2019

@infinisil oh ok. It just title says "nixos-rebuild --switch is slow", so I put my 2cents...

Have you counted how many option declarations do you have in your configs (excluding base modules)? I see that minimal configuration takes 2.74s to evaluate, but your system takes 12s (excluding docs). Module system author says it is linear in number of modules+number of options+number of option declarations, which makes me wonder, what goes wrong.

@infinisil
Copy link
Member Author

infinisil commented Dec 24, 2019

I do have a bunch of options defined on my own, it's actually how I structure my whole config (https://github.com/Infinisil/system), and I do have loads of things enabled, so I guess it makes sense that it's a bit longer. The fact that a minimal system already takes almost 3 seconds to evaluate is what's annoying me here, and the fact that it increases over time!

@infinisil
Copy link
Member Author

Just yesterday I brainstormed some ideas for a NixOS module rewrite with performance (and security) in mind which could solve this problem. It would also be almost backwards compatible and integrate well with Flakes too. It would take a while to implement however, not sure how I can find the time for it. I think such a rewrite might be our best bet of fixing this unfortunately.

@danbst
Copy link
Contributor

danbst commented Dec 25, 2019

@infinisil I was dissecting your config, here is what I found:

  • home-manager modules increase instantiate time, x2 for orakel machine. I've had 5 sec instantiate time, but when I removed all home-manager usages (home configs), time dropped to 2.5-3 sec.
  • some packages (!!) increase instantiate time. pkgs.beets, pkgs.mpd, pkgs.youtube-dl. After removing those instantiate time dropped to 2.3s.
  • minimal system instantiates in 1.5s for me
  • I've also went ahead and removed ~790 modules from module-list.nix, removed as many as possible for orakel to instantiate. Instantiate time dropped to 1.6s for orakel, and to 1.2s for minimal config.
  • with home-manager left as is and ~790 modules removed, instantiate time dropped to 4.1s for orakel.

So far my conclusions are:

  • big number of modules in module-list.nix affects instantiate time, but not that much
  • big problems are attrset options which have lots of attrnames: services.* and systemd.*. Zipping those for every module takes time. Perhaps if we split those into more hierarchical structure (balanced tree), we can have a speedup.
  • home-manager config is best to run separately
  • there must be a way to measure nixos instantiation without measuring overhead of pkgs evaluation. While pkgs attrset is fast because of laziness, it's attrvalues may not be that fast.
Minimal set of modules for `orakel`
[
  ./config/fonts/fontconfig.nix
  ./config/fonts/fontconfig-penultimate.nix
  ./config/fonts/fontdir.nix
  ./config/fonts/fonts.nix
  ./config/fonts/ghostscript.nix
  ./config/xdg/autostart.nix
  ./config/xdg/icons.nix
  ./config/xdg/menus.nix
  ./config/xdg/mime.nix
  ./config/xdg/portal.nix
  ./config/appstream.nix
  ./config/xdg/sounds.nix
  ./config/i18n.nix
  ./config/krb5/default.nix
  ./config/locale.nix
  ./config/pulseaudio.nix
  ./config/qt5.nix
  ./config/resolvconf.nix
  ./config/vte.nix
  ./hardware/all-firmware.nix
  ./hardware/ckb-next.nix
  ./hardware/device-tree.nix
  ./hardware/ksm.nix
  ./hardware/printers.nix
  ./hardware/steam-hardware.nix
  ./i18n/input-method/default.nix
  ./i18n/input-method/fcitx.nix
  ./i18n/input-method/ibus.nix
  ./i18n/input-method/nabi.nix
  ./i18n/input-method/uim.nix
  ./misc/documentation.nix
  ./misc/label.nix
  ./misc/passthru.nix
  ./programs/chromium.nix
  ./programs/dconf.nix
  ./programs/evince.nix
  ./programs/file-roller.nix
  ./programs/fuse.nix
  ./programs/gnome-disks.nix
  ./programs/gnome-documents.nix
  ./programs/gnome-terminal.nix
  ./programs/nm-applet.nix
  ./programs/seahorse.nix
  ./programs/system-config-printer.nix
  ./programs/zsh/oh-my-zsh.nix
  ./programs/zsh/zsh.nix
  ./programs/zsh/zsh-autoenv.nix
  ./programs/zsh/zsh-autosuggestions.nix
  ./programs/zsh/zsh-syntax-highlighting.nix
  ./rename.nix
  ./security/acme.nix
  ./security/apparmor.nix
  ./security/audit.nix
  ./security/chromium-suid-sandbox.nix
  ./security/dhparams.nix
  ./security/google_oslogin.nix
  ./security/misc.nix
  ./security/oath.nix
  ./security/polkit.nix
  ./security/rtkit.nix
  ./security/sudo.nix
  ./services/audio/alsa.nix
  ./services/audio/mpd.nix
  ./services/backup/rsnapshot.nix
  ./services/backup/znapzend.nix
  ./services/desktops/accountsservice.nix
  ./services/desktops/bamf.nix
  ./services/desktops/dleyna-renderer.nix
  ./services/desktops/dleyna-server.nix
  ./services/desktops/pantheon/contractor.nix
  ./services/desktops/pantheon/files.nix
  ./services/desktops/geoclue2.nix
  ./services/desktops/gsignond.nix
  ./services/desktops/gvfs.nix
  ./services/desktops/gnome3/at-spi2-core.nix
  ./services/desktops/gnome3/chrome-gnome-shell.nix
  ./services/desktops/gnome3/evolution-data-server.nix
  ./services/desktops/gnome3/glib-networking.nix
  ./services/desktops/gnome3/gnome-initial-setup.nix
  ./services/desktops/gnome3/gnome-keyring.nix
  ./services/desktops/gnome3/gnome-online-accounts.nix
  ./services/desktops/gnome3/gnome-online-miners.nix
  ./services/desktops/gnome3/gnome-remote-desktop.nix
  ./services/desktops/gnome3/gnome-settings-daemon.nix
  ./services/desktops/gnome3/gnome-user-share.nix
  ./services/desktops/gnome3/rygel.nix
  ./services/desktops/gnome3/sushi.nix
  ./services/desktops/gnome3/tracker.nix
  ./services/desktops/gnome3/tracker-miners.nix
  ./services/desktops/system-config-printer.nix
  ./services/desktops/telepathy.nix
  ./services/desktops/tumbler.nix
  ./services/desktops/zeitgeist.nix
  ./services/hardware/acpid.nix
  ./services/hardware/actkbd.nix
  ./services/hardware/bluetooth.nix
  ./services/hardware/bolt.nix
  ./services/hardware/brltty.nix
  ./services/hardware/fancontrol.nix
  ./services/hardware/freefall.nix
  ./services/hardware/fwupd.nix
  ./services/hardware/illum.nix
  ./services/hardware/interception-tools.nix
  ./services/hardware/irqbalance.nix
  ./services/hardware/lcd.nix
  ./services/hardware/lirc.nix
  ./services/hardware/nvidia-optimus.nix
  ./services/hardware/pcscd.nix
  ./services/hardware/pommed.nix
  ./services/hardware/ratbagd.nix
  ./services/hardware/sane.nix
  ./services/hardware/sane_extra_backends/brscan4.nix
  ./services/hardware/sane_extra_backends/dsseries.nix
  ./services/hardware/tcsd.nix
  ./services/hardware/tlp.nix
  ./services/hardware/thinkfan.nix
  ./services/hardware/throttled.nix
  ./services/hardware/trezord.nix
  ./services/hardware/triggerhappy.nix
  ./services/hardware/u2f.nix
  ./services/hardware/udev.nix
  ./services/hardware/udisks2.nix
  ./services/hardware/upower.nix
  ./services/hardware/usbmuxd.nix
  ./services/logging/rsyslogd.nix
  ./services/logging/syslog-ng.nix
  ./services/logging/syslogd.nix
  ./services/mail/clamsmtp.nix
  ./services/mail/dovecot.nix
  ./services/mail/mail.nix
  ./services/mail/opendkim.nix
  ./services/mail/pfix-srsd.nix
  ./services/mail/postfix.nix
  ./services/mail/postgrey.nix
  ./services/mail/rspamd.nix
  ./services/misc/nix-optimise.nix
  ./services/misc/packagekit.nix
  ./services/misc/tautulli.nix
  ./services/misc/sssd.nix
  ./services/misc/taskserver
  ./services/monitoring/monit.nix
  ./services/monitoring/vnstat.nix
  ./services/network-filesystems/ipfs.nix
  ./services/network-filesystems/samba.nix
  ./services/networking/avahi-daemon.nix
  ./services/networking/ddclient.nix
  ./services/networking/dhcpd.nix
  ./services/networking/iodine.nix
  ./services/networking/iwd.nix
  ./services/networking/kresd.nix
  ./services/networking/nat.nix
  ./services/networking/networkmanager.nix
  ./services/networking/openvpn.nix
  ./services/networking/racoon.nix
  ./services/networking/radicale.nix
  ./services/networking/znc/default.nix
  ./services/printing/cupsd.nix
  ./services/scheduling/cron.nix
  ./services/security/clamav.nix
  ./services/system/localtime.nix
  ./services/torrent/deluge.nix
  ./services/torrent/transmission.nix
  ./services/ttys/agetty.nix
  ./services/web-servers/nginx/default.nix
  ./services/x11/colord.nix
  ./services/x11/hardware/libinput.nix
  ./services/x11/hardware/multitouch.nix
  ./services/x11/hardware/synaptics.nix
  ./services/x11/hardware/wacom.nix
  ./services/x11/gdk-pixbuf.nix
  ./system/boot/binfmt.nix
  ./system/boot/grow-partition.nix
  ./system/boot/timesyncd.nix
  ./system/boot/tmp.nix
  ./tasks/filesystems/zfs.nix
  ./tasks/scsi-link-power-management.nix
  ./virtualisation/container-config.nix
  ./virtualisation/docker.nix
  ./virtualisation/lxc.nix
  ./virtualisation/lxcfs.nix
  ./virtualisation/lxd.nix
  ./virtualisation/openvswitch.nix
  ./virtualisation/vmware-guest.nix

  ./config/fonts/fonts.nix
  ./config/ldap.nix
  ./config/networking.nix
  ./config/nsswitch.nix
  ./config/power-management.nix
  ./config/shells-environment.nix
  ./config/swap.nix
  ./config/sysctl.nix
  ./config/system-environment.nix
  ./config/system-path.nix
  ./config/users-groups.nix
  ./hardware/opengl.nix
  ./misc/assertions.nix
  ./misc/extra-arguments.nix
  ./misc/ids.nix
  ./misc/lib.nix
  ./misc/meta.nix
  ./misc/nixpkgs.nix
  ./misc/version.nix
  ./programs/bash/bash.nix
  ./programs/environment.nix
  ./programs/shadow.nix
  ./programs/ssh.nix
  ./security/pam.nix
  ./security/pam_mount.nix
  ./security/pam_usb.nix
  ./security/wrappers/default.nix
  ./services/hardware/udev.nix
  ./services/misc/nix-daemon.nix
  ./services/networking/bind.nix
  ./services/networking/dhcpcd.nix
  ./services/networking/dnsmasq.nix
  ./services/networking/firewall.nix
  ./services/networking/mstpd.nix
  ./services/networking/ssh/sshd.nix
  ./services/networking/wpa_supplicant.nix
  ./services/security/fprintd.nix
  ./services/system/dbus.nix
  ./services/system/nscd.nix
  ./services/x11/xserver.nix
  ./system/activation/activation-script.nix
  ./system/activation/top-level.nix
  ./system/boot/kernel.nix
  ./system/boot/loader/efi.nix
  ./system/boot/loader/grub/grub.nix
  ./system/boot/loader/loader.nix
  ./system/boot/modprobe.nix
  ./system/boot/resolved.nix
  ./system/boot/stage-1.nix
  ./system/boot/stage-2.nix
  ./system/boot/systemd.nix
  ./system/etc/etc.nix
  ./tasks/cpu-freq.nix
  ./tasks/filesystems.nix
  ./tasks/network-interfaces.nix
  ./virtualisation/containers.nix
]

@hedefalk

This comment has been minimized.

@infinisil infinisil added the 6.topic: module system About "NixOS" module system internals label Apr 2, 2020
@stale

This comment was marked as off-topic.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 30, 2020
@infinisil

This comment was marked as off-topic.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 1, 2020
@stale

This comment was marked as off-topic.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 31, 2021
@infinisil

This comment was marked as off-topic.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 31, 2021
@L-as
Copy link
Member

L-as commented Apr 1, 2021

Just an anecdote, but evaluating my not particularly big NixOS configuration defined with flakes takes over 1 GB of RAM and ~20 seconds just to evaluate on my aarch64 device...

If NixOS is to be usable on all devices, this is a major blocker IMO.

@nbp
Copy link
Member

nbp commented Apr 9, 2021

Without going into making RFCs, there is a hack which is possible to reduce the amount of imported modules.

Previously, NixOS modules used to be evaluated twice. A first time to compute the pkgs argument later provided to every module, and a second time to compute the configuration.

The hack I am thinking off, is that we could make a list similar to module-list.nix, but which mirror the enable flags, as well as the enable flags which are consequently being updated by these modules. Thus we can make a full list of tiny modules in order to compute the tiny list of full modules.

Another option, would be to dig enable flags ahead of the module evaluation to pre-compute the list of imported modules. This would still require to have a list of enable flags per module.

@lheckemann
Copy link
Member

@nbp I'm guessing this would only help if the system doesn't have the manual enabled though?

@stale

This comment was marked as off-topic.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 9, 2021
@tv42

This comment was marked as off-topic.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 9, 2021
@SuperSandro2000 SuperSandro2000 added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 24, 2022
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 22, 2024
@samueldr samueldr added the 5. scope: tracking Long-lived issue tracking long-term fixes or multiple sub-problems label Apr 23, 2024
@arianvp
Copy link
Member

arianvp commented May 16, 2024

So I created a very minimal module list (way smaller than @danbst one) and it evals in 3.2 seconds.

So seems we had a regression in nixos module eval performance recently :( Eval times doubled whilst the module list is smaller

https://github.com/arianvp/lolmin/actions/runs/9120699581/job/25078546117

@arianvp
Copy link
Member

arianvp commented May 18, 2024

Oh of course i dont know what machine they used.... so my statement is kinda useless.

However the minimal module list is still 2x faster than non-minimal.

Full experiment + code is here:

http://github.com/arianvp/lolmin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5. scope: tracking Long-lived issue tracking long-term fixes or multiple sub-problems 6.topic: module system About "NixOS" module system internals 6.topic: nixos
Projects
None yet
Development

No branches or pull requests