Author: arichardson Date: Sun Oct 18 18:35:23 2020 New Revision: 366815 URL: https://svnweb.freebsd.org/changeset/base/366815
Log: Significantly speed up mkimg_test It turns out that the majority of the test time for the mkimg tests isn't mkimg itself but rather the use of jot and hexdump which can be quite slow on emulated platforms such as QEMU. On QEMU-RISC-V this reduces the time for `kyua test mkimg_test` from 655 seconds to 200. And for CheriBSD on QEMU-CHERI this saves 4-5 hours (25% of the time for the entire testsuite!) since jot ends up triggering slow functions inside the QEMU emulation a lot. Reviewed By: lwhsu Differential Revision: https://reviews.freebsd.org/D26796 Modified: head/Makefile.inc1 head/usr.bin/mkimg/tests/Makefile head/usr.bin/mkimg/tests/mkimg_test.sh Modified: head/Makefile.inc1 ============================================================================== --- head/Makefile.inc1 Sun Oct 18 17:31:10 2020 (r366814) +++ head/Makefile.inc1 Sun Oct 18 18:35:23 2020 (r366815) @@ -2342,6 +2342,8 @@ _other_bootstrap_tools+=tools/build/cross-build/fake_c .endif # mkfifo is used by sys/conf/newvers.sh _basic_bootstrap_tools+=usr.bin/mkfifo +# jot is needed for the mkimg tests +_basic_bootstrap_tools+=usr.bin/jot .if ${MK_BOOT} != "no" # md5 is used by boot/beri (and possibly others) Modified: head/usr.bin/mkimg/tests/Makefile ============================================================================== --- head/usr.bin/mkimg/tests/Makefile Sun Oct 18 17:31:10 2020 (r366814) +++ head/usr.bin/mkimg/tests/Makefile Sun Oct 18 18:35:23 2020 (r366815) @@ -15,9 +15,25 @@ $f: $f.hex sed -e '/^#.*/D' < ${.ALLSRC} > ${.TARGET} .endfor +# Note: Pre-generating this test file saves a lot of time when building on +# emulated platforms such as QEMU. It can take about 2-5 seconds to generate +# the test file using jot (depending on the emulated architecture) and this +# is done for each of the 168 test configurations. +# The effect is even more pronounced on CHERI-RISCV QEMU (emulating CHERI inside +# QEMU adds additional run-time overhead): Running the apm_1x1_512_raw without +# the pre-generated file takes about 108 seconds of which 102 seconds (over 95%) +# were spent running jot -b. It's even worse on CHERI-MIPS QEMU: 187 seconds +# for jot -b P 2097152 > /dev/null. By using a pre-generated 4MB file, the +# slowest test variant (vtoc8_63x255_4096_vhdx) now only takes 29 seconds (of +# which 26s are spent in hexdump -C) instead of previously 2min30s. +${PACKAGE}FILES+= partition_data_4M.bin +partition_data_4M.bin: Makefile + jot -b P 2097152 > ${.TARGET} || rm -f ${.TARGET} + CLEANFILES+= ${${PACKAGE}FILES}} -rebase: .PHONY - (cd ${.CURDIR}; /usr/libexec/atf-sh ${_REBASE_SCRIPT}.sh rebase) +rebase: partition_data_4M.bin ${_REBASE_SCRIPT} .PHONY + cd ${.CURDIR}; PATH=${.OBJDIR}/..:$${PATH}:/usr/bin:/bin \ + /usr/libexec/atf-sh ${.OBJDIR}/${_REBASE_SCRIPT} -s ${.OBJDIR} rebase .include <bsd.test.mk> Modified: head/usr.bin/mkimg/tests/mkimg_test.sh ============================================================================== --- head/usr.bin/mkimg/tests/mkimg_test.sh Sun Oct 18 17:31:10 2020 (r366814) +++ head/usr.bin/mkimg/tests/mkimg_test.sh Sun Oct 18 18:35:23 2020 (r366815) @@ -56,7 +56,7 @@ makeimage() if test -z "$partarg"; then local swap ufs swap="-p freebsd-swap::128K" - ufs="-p freebsd-ufs:=`mkcontents P 4194304`" + ufs="-p freebsd-ufs:=$(atf_get_srcdir)/partition_data_4M.bin" partarg="$ufs $swap" fi _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"