mirror of https://github.com/dynup/kpatch
kpatch-build: deep find performance improvement
If we have to do a deep find (e.g. search the entire tree) to find a parent object, first try searching in the last successful deep find directory. This is a performance improvement in the case of a full tree rebuild, because deep finds are very expensive, and it's not uncommon for there to be multiple objects in a directory being linked into an object in another directory.
This commit is contained in:
parent
a851517165
commit
8c2792af6c
|
@ -129,8 +129,16 @@ find_parent_obj() {
|
||||||
grepname=${1%.o}
|
grepname=${1%.o}
|
||||||
grepname=$grepname\\\.o
|
grepname=$grepname\\\.o
|
||||||
if [[ $DEEP_FIND -eq 1 ]]; then
|
if [[ $DEEP_FIND -eq 1 ]]; then
|
||||||
parent=$(find . -name ".*.cmd" | xargs grep -l $grepname | grep -v $dir/.${file}.cmd)
|
num=0
|
||||||
num=$(find . -name ".*.cmd" | xargs grep -l $grepname | grep -v $dir/.${file}.cmd | wc -l)
|
if [[ -n $last_deep_find ]]; then
|
||||||
|
parent=$(grep -l $grepname $last_deep_find/.*.cmd | grep -v $dir/.${file}.cmd)
|
||||||
|
num=$(grep -l $grepname $last_deep_find/.*.cmd | grep -v $dir/.${file}.cmd |wc -l)
|
||||||
|
fi
|
||||||
|
if [[ $num -eq 0 ]]; then
|
||||||
|
parent=$(find * -name ".*.cmd" | xargs grep -l $grepname | grep -v $dir/.${file}.cmd)
|
||||||
|
num=$(find * -name ".*.cmd" | xargs grep -l $grepname | grep -v $dir/.${file}.cmd | wc -l)
|
||||||
|
[[ $num -eq 1 ]] && last_deep_find=$(dirname $parent)
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
parent=$(grep -l $grepname $dir/.*.cmd | grep -v $dir/.${file}.cmd)
|
parent=$(grep -l $grepname $dir/.*.cmd | grep -v $dir/.${file}.cmd)
|
||||||
num=$(grep -l $grepname $dir/.*.cmd | grep -v $dir/.${file}.cmd | wc -l)
|
num=$(grep -l $grepname $dir/.*.cmd | grep -v $dir/.${file}.cmd | wc -l)
|
||||||
|
@ -150,11 +158,10 @@ find_parent_obj() {
|
||||||
find_kobj() {
|
find_kobj() {
|
||||||
arg=$1
|
arg=$1
|
||||||
KOBJFILE=$arg
|
KOBJFILE=$arg
|
||||||
dir=$(dirname $KOBJFILE)
|
|
||||||
file=$(basename $KOBJFILE)
|
|
||||||
DEEP_FIND=0
|
DEEP_FIND=0
|
||||||
while true; do
|
while true; do
|
||||||
find_parent_obj $KOBJFILE
|
find_parent_obj $KOBJFILE
|
||||||
|
[[ -n $PARENT ]] && DEEP_FIND=0
|
||||||
if [[ -z $PARENT ]]; then
|
if [[ -z $PARENT ]]; then
|
||||||
[[ $KOBJFILE = *.ko ]] && return
|
[[ $KOBJFILE = *.ko ]] && return
|
||||||
case $KOBJFILE in
|
case $KOBJFILE in
|
||||||
|
|
Loading…
Reference in New Issue