mirror of https://github.com/containers/podman.git
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 <rothberg@redhat.com>
This commit is contained in:
parent
d2291ecdd5
commit
aa28dbbf88
5
Makefile
5
Makefile
|
@ -20,6 +20,7 @@ SHAREDIR_CONTAINERS ?= ${PREFIX}/share/containers
|
||||||
ETCDIR ?= /etc
|
ETCDIR ?= /etc
|
||||||
TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d
|
TMPFILESDIR ?= ${PREFIX}/lib/tmpfiles.d
|
||||||
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
|
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
|
||||||
|
BUILDFLAGS ?=
|
||||||
BUILDTAGS ?= \
|
BUILDTAGS ?= \
|
||||||
$(shell hack/apparmor_tag.sh) \
|
$(shell hack/apparmor_tag.sh) \
|
||||||
$(shell hack/btrfs_installed_tag.sh) \
|
$(shell hack/btrfs_installed_tag.sh) \
|
||||||
|
@ -147,10 +148,10 @@ test/goecho/goecho: .gopathok $(wildcard test/goecho/*.go)
|
||||||
$(GO) build -ldflags '$(LDFLAGS)' -o $@ $(PROJECT)/test/goecho
|
$(GO) build -ldflags '$(LDFLAGS)' -o $@ $(PROJECT)/test/goecho
|
||||||
|
|
||||||
podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman
|
podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman
|
||||||
$(GO) build -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o bin/$@ $(PROJECT)/cmd/podman
|
$(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o bin/$@ $(PROJECT)/cmd/podman
|
||||||
|
|
||||||
podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote environment
|
podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote environment
|
||||||
$(GO) build -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o bin/$@ $(PROJECT)/cmd/podman
|
$(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o bin/$@ $(PROJECT)/cmd/podman
|
||||||
|
|
||||||
podman-remote-darwin: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote OSX environment
|
podman-remote-darwin: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote OSX environment
|
||||||
CGO_ENABLED=0 GOOS=darwin $(GO) build -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "remoteclient containers_image_openpgp exclude_graphdriver_devicemapper" -o bin/$@ $(PROJECT)/cmd/podman
|
CGO_ENABLED=0 GOOS=darwin $(GO) build -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "remoteclient containers_image_openpgp exclude_graphdriver_devicemapper" -o bin/$@ $(PROJECT)/cmd/podman
|
||||||
|
|
|
@ -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"
|
Loading…
Reference in New Issue