Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ nixpkgs, pkgs }: 2 3with pkgs; 4 5runCommand "nixpkgs-metrics" 6 { 7 nativeBuildInputs = 8 with pkgs.lib; 9 map getBin [ 10 nix 11 time 12 jq 13 ]; 14 # see https://github.com/NixOS/nixpkgs/issues/52436 15 #requiredSystemFeatures = [ "benchmark" ]; # dedicated `t2a` machine, by @vcunat 16 } 17 '' 18 export NIX_STORE_DIR=$TMPDIR/store 19 export NIX_STATE_DIR=$TMPDIR/state 20 export NIX_PAGER= 21 nix-store --init 22 23 mkdir -p $out/nix-support 24 touch $out/nix-support/hydra-build-products 25 26 run() { 27 local name="$1" 28 shift 29 30 echo "running $@" 31 32 case "$name" in 33 # Redirect stdout to /dev/null to avoid hitting "Output Limit 34 # Exceeded" on Hydra. 35 nix-env.qaDrv|nix-env.qaDrvAggressive) 36 NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" >/dev/null ;; 37 *) 38 NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" ;; 39 esac 40 41 cat stats-nix; echo; cat stats-time; echo 42 43 x=$(jq '.cpuTime' < stats-nix) 44 [[ -n $x ]] || exit 1 45 echo "$name.time $x s" >> $out/nix-support/hydra-metrics 46 47 x=$(sed -e 's/.* \([0-9]\+\)maxresident.*/\1/ ; t ; d' < stats-time) 48 [[ -n $x ]] || exit 1 49 echo "$name.maxresident $x KiB" >> $out/nix-support/hydra-metrics 50 51 # nix-2.2 also outputs .symbols.bytes but that wasn't summed originally 52 # https://github.com/NixOS/nix/pull/2392/files#diff-8e6ba8c21672fc1a5f6f606e1e101c74L1762 53 x=$(jq '[.envs,.list,.values,.sets] | map(.bytes) | add' < stats-nix) 54 [[ -n $x ]] || exit 1 55 echo "$name.allocations $x B" >> $out/nix-support/hydra-metrics 56 57 x=$(jq '.values.number' < stats-nix) 58 [[ -n $x ]] || exit 1 59 echo "$name.values $x" >> $out/nix-support/hydra-metrics 60 } 61 62 run nixos.smallContainer nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \ 63 -A closures.smallContainer.x86_64-linux --show-trace 64 run nixos.kde nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \ 65 -A closures.kde.x86_64-linux --show-trace 66 run nixos.lapp nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \ 67 -A closures.lapp.x86_64-linux --show-trace 68 run nix-env.qa nix-env -f ${nixpkgs} -qa 69 run nix-env.qaDrv nix-env -f ${nixpkgs} -qa --drv-path --meta --xml 70 71 # It's slightly unclear which of the set to track: qaCount, qaCountDrv, qaCountBroken. 72 num=$(nix-env -f ${nixpkgs} -qa | wc -l) 73 echo "nix-env.qaCount $num" >> $out/nix-support/hydra-metrics 74 qaCountDrv=$(nix-env -f ${nixpkgs} -qa --drv-path | wc -l) 75 num=$((num - $qaCountDrv)) 76 echo "nix-env.qaCountBroken $num" >> $out/nix-support/hydra-metrics 77 78 # TODO: this has been ignored for some time 79 # GC Warning: Bad initial heap size 128k - ignoring it. 80 #export GC_INITIAL_HEAP_SIZE=128k 81 run nix-env.qaAggressive nix-env -f ${nixpkgs} -qa 82 run nix-env.qaDrvAggressive nix-env -f ${nixpkgs} -qa --drv-path --meta --xml 83 84 lines=$(find ${nixpkgs} -name "*.nix" -type f | xargs cat | wc -l) 85 echo "loc $lines" >> $out/nix-support/hydra-metrics 86 ''