[v2] devtools: parallelize ABI check
Checks
Commit Message
Generation and comparison of ABI dumps are done on multiple cores
thanks to xargs -P0.
It can accelerate this long step by 5 in my tests.
xargs reports a global error if one of the process has an error.
Running a shell function with xargs requires to export it with -f,
and that is a specific capability of bash.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
v2:
- find dump2 inside the function
- force bash because of export -f
---
devtools/check-abi.sh | 20 +++++++++++++-------
devtools/gen-abi.sh | 5 +++--
2 files changed, 16 insertions(+), 9 deletions(-)
Comments
On 1/9/2023 9:34 AM, Thomas Monjalon wrote:
> Generation and comparison of ABI dumps are done on multiple cores
> thanks to xargs -P0.
> It can accelerate this long step by 5 in my tests.
>
> xargs reports a global error if one of the process has an error.
>
> Running a shell function with xargs requires to export it with -f,
> and that is a specific capability of bash.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> v2:
> - find dump2 inside the function
> - force bash because of export -f
It reduces script runtime ~2mins in my test.
Tested-by: Ferruh Yigit <ferruh.yigit@amd.com>
@@ -1,4 +1,4 @@
-#!/bin/sh -e
+#!/bin/bash -e
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2019 Red Hat, Inc.
@@ -34,19 +34,18 @@ else
ABIDIFF_OPTIONS="$ABIDIFF_OPTIONS --headers-dir2 $incdir2"
fi
-error=
-for dump in $(find $refdir -name "*.dump"); do
+run_diff() { # <dump1> <dir2>
+ dump=$1
+ newdir=$2
name=$(basename $dump)
dump2=$(find $newdir -name $name)
if [ -z "$dump2" ] || [ ! -e "$dump2" ]; then
echo "Error: cannot find $name in $newdir" >&2
- error=1
- continue
+ return 1
fi
abidiff $ABIDIFF_OPTIONS $dump $dump2 || {
abiret=$?
echo "Error: ABI issue reported for 'abidiff $ABIDIFF_OPTIONS $dump $dump2'" >&2
- error=1
echo
if [ $(($abiret & 3)) -ne 0 ]; then
echo "ABIDIFF_ERROR|ABIDIFF_USAGE_ERROR, this could be a script or environment issue." >&2
@@ -58,7 +57,14 @@ for dump in $(find $refdir -name "*.dump"); do
echo "ABIDIFF_ABI_INCOMPATIBLE_CHANGE, this change breaks the ABI." >&2
fi
echo
+ return 1
}
-done
+}
+export -f run_diff
+
+error=
+find $refdir -name "*.dump" |
+xargs -n1 -P0 sh -c 'run_diff $0 '$newdir ||
+error=1
[ -z "$error" ] || [ -n "$warnonly" ]
@@ -22,5 +22,6 @@ for f in $(find $installdir -name "*.so.*"); do
fi
libname=$(basename $f)
- abidw --out-file $dumpdir/${libname%.so*}.dump $f
-done
+ echo $dumpdir/${libname%.so*}.dump $f
+done |
+xargs -n2 -P0 abidw --out-file