Why NixOS has consistently worse CPU performance compared to ubuntu?

Most likely caused by compiler flags, for example, nixpkgs does not enable LTO by default, but Arch Linux, Ubuntu, Fedora, OpenSUSE and more enable it by default.
More examples:

  1. for reproducibility disable pgo for clang
  2. Nix compiled Python is slower
  3. firefox is slower than firefox-bin

Issue 3 has been resolved, but 1 and 2 and possibly other packages are slower on NixOS than other distributions

I tired KDE Linux in a virtual machine, and it’s even faster than my host os (NixOS).
This might be caused by the explosion of env vars like XDG_DATA_DIRS, though most of the time, it should only slow down startup.

EDIT: I think “disable pgo for clang” is not entirely correct, pgo is not enabled for clang in most other distros either. Python is indeed slower.

3 Likes