From 0e1fdd528bfce85c5da72832252599810c1d14ca Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 01:59:26 +0800 Subject: [PATCH 1/4] add bloat analyzer script to local builds --- analyze-bloat.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 analyze-bloat.sh diff --git a/analyze-bloat.sh b/analyze-bloat.sh new file mode 100755 index 000000000..f98dca856 --- /dev/null +++ b/analyze-bloat.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +declare -a Crates=( + "kernel" + "loader" + "gam" + "status" + "shellchat" + "ime-frontend" + "ime-plugin-shell" + "graphics-server" + "ticktimer-server" + "log-server" + "com" + "xous-names" + "keyboard" + "trng" + "llio" + "susres" + "codec" + "sha2" + "engine-25519" + "spinor" + "root-keys" + "jtag" + "net" + "dns" + "pddb" + "modals" + "usb-device-xous" + "vault" + "ball" + "repl" +) + +if [ -e "$HOME/.cargo/env" ]; then + . "$HOME/.cargo/env" +fi +RISCV_TOOLS=/opt/riscv64-unknown-elf +export PATH=$RISCV_TOOLS/bin:$PATH + +env | sort > env.txt + +#cargo clean +mkdir -p reports +mkdir -p reports/old +# move just the files, not the directory +find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv -n {} reports/old/ \; + +echo "===== TURNING OF STRIP =====" +sed -i 's/strip = true/strip = false/g' Cargo.toml + +echo "===== STARTING BUILD at $(date) =====" +cargo xtask app-image ball repl vault + +echo "===== ANALYZING at $(date) =====" +for val in ${Crates[@]}; do + # dump the header summary + riscv64-unknown-elf-objdump -h target/riscv32imac-unknown-xous-elf/release/$val > reports/$val.txt + # dump the sorted list of objects + riscv64-unknown-elf-nm -r --size-sort --print-size target/riscv32imac-unknown-xous-elf/release/$val | rustfilt >> reports/$val.txt + # dump the disassembly + riscv64-unknown-elf-objdump -S -d target/riscv32imac-unknown-xous-elf/release/$val | rustfilt > reports/$val.list +done + + +echo "===== REVERTING STRIP =====" +git checkout Cargo.toml From a92cf4e9c08c3016b99697bfb2db98af11a74693 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 02:00:05 +0800 Subject: [PATCH 2/4] ignore bloat analyzer reports --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index dc5a7b4b3..b807ee298 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ emulation/linux-server-rootfs.jffs2 # don't commit local modifications to the Renode filesystem template emulation/linux-server-rootfs.jffs2 + +# bloat analyzer reports +reports/ \ No newline at end of file From 28f54229c7827ee3dd6623f89b097f3b335b7d5c Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 02:03:06 +0800 Subject: [PATCH 3/4] fix typo --- analyze-bloat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyze-bloat.sh b/analyze-bloat.sh index f98dca856..f7adbd7e4 100755 --- a/analyze-bloat.sh +++ b/analyze-bloat.sh @@ -47,7 +47,7 @@ mkdir -p reports/old # move just the files, not the directory find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv -n {} reports/old/ \; -echo "===== TURNING OF STRIP =====" +echo "===== TURNING OFF STRIP =====" sed -i 's/strip = true/strip = false/g' Cargo.toml echo "===== STARTING BUILD at $(date) =====" From 0abca4229845a4137d0d7e06ef289b5ca64f6302 Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 14 Jun 2022 02:05:31 +0800 Subject: [PATCH 4/4] fix argument to backup copy --- analyze-bloat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyze-bloat.sh b/analyze-bloat.sh index f7adbd7e4..2aba5a7ed 100755 --- a/analyze-bloat.sh +++ b/analyze-bloat.sh @@ -45,7 +45,7 @@ env | sort > env.txt mkdir -p reports mkdir -p reports/old # move just the files, not the directory -find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv -n {} reports/old/ \; +find reports/ -maxdepth 1 -type f -name '[!.]*' -exec mv {} reports/old/ \; echo "===== TURNING OFF STRIP =====" sed -i 's/strip = true/strip = false/g' Cargo.toml