nix-output-monitor icon indicating copy to clipboard operation
nix-output-monitor copied to clipboard

Big slowdown with very big build logs

Open K900 opened this issue 1 year ago • 6 comments

With this derivation:

{ pkgs ? (import <nixpkgs> {}) }:
pkgs.stdenv.mkDerivation {
  name = "robot-that-screams";
  buildCommand = ''
    for _ in {0..1000000}; do
      echo AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    done
  '';
}

nix-build runs in under 10 seconds:

nix-build -v --log-format internal-json &> /dev/null  1.89s user 0.79s system 33% cpu 7.898 total

nom-build takes minutes (exact time TBC)

nom-build &> /dev/null  4344.87s user 1614.41s system 114% cpu 1:26:59.89 total

K900 avatar May 13 '23 14:05 K900

Some more ad-hoc testing: 10k lines finishes in 3 seconds, 100k lines finishes in under a minute, 200k lines takes 8 minutes, which sounds ... cubic, possibly?

K900 avatar May 13 '23 15:05 K900

Thank you! That's excellent debugging data. I have already fixed a number of space leaks a few weeks ago. So maybe this is already better on main.

I will get to this, when I have the time.

maralorn avatar May 13 '23 16:05 maralorn

I just tried 791e8e and it's much better - 25 seconds for the initial 1 million lines test. This is still considerably slower than nix-build's 8 seconds, but a lot more usable than multiple hours. Maybe you could cut a new release with the current changes?

K900 avatar May 13 '23 17:05 K900

Yeah, I probably should. Sadly there are a few modifications in main which I consider experimental and don't want to release into the wild without polishing them.

maralorn avatar May 14 '23 08:05 maralorn

I have published a new release and opened a PR against Nixpkgs in https://github.com/NixOS/nixpkgs/pull/231922.

I will leave this issue open until I have debugged the remaining performance difference between nom-build and nix-build.

maralorn avatar May 14 '23 21:05 maralorn

I still haven’t profiled this issue exactly, but one obvious problem came to mind, which I have fixed on main, reducing test time by another 50%.

I quite consciously had decided, that I will never need to buffer a lot of output at the same time. Don’t ask me why I did that, but it’s at least partially fixed now.

maralorn avatar May 14 '23 22:05 maralorn