From aa28dbbf8876bd749379ba9540d7cc103bd56291 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 1 Jul 2019 17:29:09 +0200 Subject: analyse package sizes Analyse the size of all go-packages used during the build process via the newly added `hack/analyses/go-archive-analysis.sh` script. The script expects the `WORK` environment variable to be set, which points to a temporary work directory generated by `go build`. To generate such a work directory, set the `BUILDFLAGS="-work -a"`: * `-work` for creating the work directory * `-a` to force rebuilding all packages even when already cached The workflow may look as follows: ``` $ BUILDFLAGS="-work -a" make podman [...] WORK=/tmp/go-build127001249 $ WORK=/tmp/go-build127001249 ./hack/analyses/go-archive-analysis.sh ``` The output of the script has the format `$SIZE $PACKAGE` where $SIZE is the size of the compiled version of the go package (i.e., `.a` file) and $PACKAGE for the corresponding package, for instance, `math/big` for a stdlib package or vendor/... for vendored packages. Credits to the authors of https://github.com/jondot/goweight, which inspired this work. Signed-off-by: Valentin Rothberg --- hack/analyses/go-archive-analysis.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 hack/analyses/go-archive-analysis.sh (limited to 'hack') diff --git a/hack/analyses/go-archive-analysis.sh b/hack/analyses/go-archive-analysis.sh new file mode 100755 index 000000000..8f3a110d6 --- /dev/null +++ b/hack/analyses/go-archive-analysis.sh @@ -0,0 +1,15 @@ +#!/usr/bin/bash + +if [ -z "$WORK" ] +then + echo "WORK environment variable must be set" + exit 1 +fi + +DATA=$(grep --no-filename packagefile $WORK/**/importcfg \ + | awk '{ split($2, data, "="); printf "%s ", data[1]; system("du -sh " data[2]) }' \ + | awk '{ printf "%s %s\n", $2, $1 }' \ + | sort -ruh \ + ) + +echo "$DATA" -- cgit v1.2.3-54-g00ecf