2016-03-24 16:36:26 +00:00
|
|
|
{ nixpkgs, pkgs }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
runCommand "nixpkgs-metrics"
|
2019-01-13 09:31:02 +00:00
|
|
|
{ nativeBuildInputs = with pkgs.lib; map getBin [ nix time jq ];
|
2022-05-13 10:42:34 +01:00
|
|
|
# see https://github.com/NixOS/nixpkgs/issues/52436
|
|
|
|
#requiredSystemFeatures = [ "benchmark" ]; # dedicated `t2a` machine, by @vcunat
|
2016-03-24 16:36:26 +00:00
|
|
|
}
|
|
|
|
''
|
2021-11-11 16:58:24 +00:00
|
|
|
export NIX_STORE_DIR=$TMPDIR/store
|
|
|
|
export NIX_STATE_DIR=$TMPDIR/state
|
2021-09-27 15:23:09 +01:00
|
|
|
export NIX_PAGER=
|
2016-03-24 16:36:26 +00:00
|
|
|
nix-store --init
|
|
|
|
|
|
|
|
mkdir -p $out/nix-support
|
2016-03-24 17:06:46 +00:00
|
|
|
touch $out/nix-support/hydra-build-products
|
2016-03-24 16:36:26 +00:00
|
|
|
|
|
|
|
run() {
|
|
|
|
local name="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
echo "running $@"
|
2019-06-07 20:30:54 +01:00
|
|
|
|
|
|
|
case "$name" in
|
|
|
|
# Redirect stdout to /dev/null to avoid hitting "Output Limit
|
|
|
|
# Exceeded" on Hydra.
|
|
|
|
nix-env.qaDrv|nix-env.qaDrvAggressive)
|
2021-09-27 15:23:09 +01:00
|
|
|
NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" >/dev/null ;;
|
2019-06-07 20:30:54 +01:00
|
|
|
*)
|
2021-09-27 15:23:09 +01:00
|
|
|
NIX_SHOW_STATS=1 NIX_SHOW_STATS_PATH=stats-nix time -o stats-time "$@" ;;
|
2019-06-07 20:30:54 +01:00
|
|
|
esac
|
|
|
|
|
2019-01-13 09:31:02 +00:00
|
|
|
cat stats-nix; echo; cat stats-time; echo
|
2016-03-24 16:36:26 +00:00
|
|
|
|
2019-01-13 09:31:02 +00:00
|
|
|
x=$(jq '.cpuTime' < stats-nix)
|
2016-03-24 16:36:26 +00:00
|
|
|
[[ -n $x ]] || exit 1
|
|
|
|
echo "$name.time $x s" >> $out/nix-support/hydra-metrics
|
|
|
|
|
2019-01-13 09:31:02 +00:00
|
|
|
x=$(sed -e 's/.* \([0-9]\+\)maxresident.*/\1/ ; t ; d' < stats-time)
|
2016-03-24 16:36:26 +00:00
|
|
|
[[ -n $x ]] || exit 1
|
|
|
|
echo "$name.maxresident $x KiB" >> $out/nix-support/hydra-metrics
|
|
|
|
|
2019-01-13 09:31:02 +00:00
|
|
|
# nix-2.2 also outputs .symbols.bytes but that wasn't summed originally
|
|
|
|
# https://github.com/NixOS/nix/pull/2392/files#diff-8e6ba8c21672fc1a5f6f606e1e101c74L1762
|
|
|
|
x=$(jq '[.envs,.list,.values,.sets] | map(.bytes) | add' < stats-nix)
|
2016-03-24 16:36:26 +00:00
|
|
|
[[ -n $x ]] || exit 1
|
|
|
|
echo "$name.allocations $x B" >> $out/nix-support/hydra-metrics
|
|
|
|
|
2019-01-13 09:31:02 +00:00
|
|
|
x=$(jq '.values.number' < stats-nix)
|
2016-03-24 16:36:26 +00:00
|
|
|
[[ -n $x ]] || exit 1
|
|
|
|
echo "$name.values $x" >> $out/nix-support/hydra-metrics
|
|
|
|
}
|
|
|
|
|
2017-11-25 06:07:27 +00:00
|
|
|
run nixos.smallContainer nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
|
|
|
|
-A closures.smallContainer.x86_64-linux --show-trace
|
|
|
|
run nixos.kde nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
|
|
|
|
-A closures.kde.x86_64-linux --show-trace
|
|
|
|
run nixos.lapp nix-instantiate --dry-run ${nixpkgs}/nixos/release.nix \
|
|
|
|
-A closures.lapp.x86_64-linux --show-trace
|
2016-03-24 16:36:26 +00:00
|
|
|
run nix-env.qa nix-env -f ${nixpkgs} -qa
|
|
|
|
run nix-env.qaDrv nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
|
|
|
|
|
2019-03-01 12:59:30 +00:00
|
|
|
# It's slightly unclear which of the set to track: qaCount, qaCountDrv, qaCountBroken.
|
2018-08-18 17:38:14 +01:00
|
|
|
num=$(nix-env -f ${nixpkgs} -qa | wc -l)
|
|
|
|
echo "nix-env.qaCount $num" >> $out/nix-support/hydra-metrics
|
2019-03-01 12:59:30 +00:00
|
|
|
qaCountDrv=$(nix-env -f ${nixpkgs} -qa --drv-path | wc -l)
|
|
|
|
num=$((num - $qaCountDrv))
|
|
|
|
echo "nix-env.qaCountBroken $num" >> $out/nix-support/hydra-metrics
|
2019-02-22 16:59:29 +00:00
|
|
|
|
2019-01-13 09:31:02 +00:00
|
|
|
# TODO: this has been ignored for some time
|
|
|
|
# GC Warning: Bad initial heap size 128k - ignoring it.
|
|
|
|
#export GC_INITIAL_HEAP_SIZE=128k
|
2016-03-24 16:36:26 +00:00
|
|
|
run nix-env.qaAggressive nix-env -f ${nixpkgs} -qa
|
|
|
|
run nix-env.qaDrvAggressive nix-env -f ${nixpkgs} -qa --drv-path --meta --xml
|
|
|
|
|
|
|
|
lines=$(find ${nixpkgs} -name "*.nix" -type f | xargs cat | wc -l)
|
|
|
|
echo "loc $lines" >> $out/nix-support/hydra-metrics
|
|
|
|
''
|