5 runCommand "nixpkgs-metrics"
6 { nativeBuildInputs = with pkgs.lib; map getBin [ nix time jq ];
7 requiredSystemFeatures = [ "benchmark" ]; # dedicated `t2a` machine, by @vcunat
10 export NIX_STORE_DIR=$TMPDIR/store
11 export NIX_STATE_DIR=$TMPDIR/state
15 mkdir -p $out/nix-support
16 touch $out/nix-support/hydra-build-products
25 # Redirect stdout to /dev/null to avoid hitting "Output Limit
27 nix-env.qaDrv|nix-env.qaDrvAggressive)
28 NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" >/dev/null ;;
30 NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" ;;
33 cat stats-nix; echo; cat stats-time; echo
35 x=$(jq '.cpuTime' < stats-nix)
37 echo "$name.time $x s" >> $out/nix-support/hydra-metrics
39 x=$(sed -e 's/.* \([0-9]\+\)maxresident.*/\1/ ; t ; d' < stats-time)
41 echo "$name.maxresident $x KiB" >> $out/nix-support/hydra-metrics
43 # nix-2.2 also outputs .symbols.bytes but that wasn't summed originally
44 # https://github.com/NixOS/nix/pull/2392/files#diff-8e6ba8c21672fc1a5f6f606e1e101c74L1762
45 x=$(jq '[.envs,.list,.values,.sets] | map(.bytes) | add' < stats-nix)
47 echo "$name.allocations $x B" >> $out/nix-support/hydra-metrics
49 x=$(jq '.values.number' < stats-nix)
51 echo "$name.values $x" >> $out/nix-support/hydra-metrics
54 run nixos.smallContainer nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
55 -A closures.smallContainer.x86_64-linux --show-trace
56 run nixos.kde nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
57 -A closures.kde.x86_64-linux --show-trace
58 run nixos.lapp nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
59 -A closures.lapp.x86_64-linux --show-trace
60 run nix-env.qa nix-env -f ${nixpkgs} -qa
61 run nix-env.qaDrv nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
63 # It's slightly unclear which of the set to track: qaCount, qaCountDrv, qaCountBroken.
64 num=$(nix-env -f ${nixpkgs} -qa | wc -l)
65 echo "nix-env.qaCount $num" >> $out/nix-support/hydra-metrics
66 qaCountDrv=$(nix-env -f ${nixpkgs} -qa --drv-path | wc -l)
67 num=$((num - $qaCountDrv))
68 echo "nix-env.qaCountBroken $num" >> $out/nix-support/hydra-metrics
70 # TODO: this has been ignored for some time
71 # GC Warning: Bad initial heap size 128k - ignoring it.
72 #export GC_INITIAL_HEAP_SIZE=128k
73 run nix-env.qaAggressive nix-env -f ${nixpkgs} -qa
74 run nix-env.qaDrvAggressive nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
76 lines=$(find ${nixpkgs} -name "*.nix" -type f | xargs cat | wc -l)
77 echo "loc $lines" >> $out/nix-support/hydra-metrics