From 6a7a0b84c7603284982a43b61891b45445dc14b7 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 25 Aug 2016 01:59:23 -0700 Subject: [PATCH] gc.sh: cache is_xxx_mirror results for efficiency Signed-off-by: Kyle J. McKay --- jobd/gc.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/jobd/gc.sh b/jobd/gc.sh index 27f1443..c8cd8b5 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -89,7 +89,7 @@ combine_packs() { # if the current directory is_gfi_mirror then repack all packs listed in gfi-packs repack_gfi_packs() { - [ -f gfi-packs -a -s gfi-packs ] && is_gfi_mirror || return 0 + [ -n "$gfi_mirror" ] || return 0 [ -d objects/pack ] || { rm -f gfi-packs; return 0; } combine_packs --ignore-missing --no-reuse-delta /dev/null | @@ -284,7 +284,7 @@ remove_crud() { # [A-Za-z0-9_] so we can at least check that and fortunately the only # collision is 'FETCH_HEAD' but that shouldn't matter. # There may also be temp files with a Git_ prefix as well. - if is_svn_mirror; then + if [ -n "$svn_mirror" ]; then _randchar='[A-Za-z0-9_]' _randchar2="$_randchar$_randchar" _randchar4="$_randchar2$_randchar2" @@ -294,7 +294,7 @@ remove_crud() { fi # Remove any stale fast_import_crash_ files that are more than 3 days old. - if is_gfi_mirror; then + if [ -n "$gfi_mirror" ]; then find . -maxdepth 1 -type f -mmin +4320 -name "fast_import_crash_?*" -print0 | xargs -0 rm -f fi } @@ -322,6 +322,13 @@ remove_crud() { proj="${1%.git}" shift cd "$cfg_reporoot/$proj.git" +mirror_url="$(get_mirror_url)" +svn_mirror= +! is_svn_mirror_url "$mirror_url" || svn_mirror=1 +gfi_mirror= +if [ -f gfi-packs -a -s gfi-packs ] && is_gfi_mirror_url "$mirror_url"; then + gfi_mirror=1 +fi # If git config --bool --get girocco.redelta is explicitly false then automatic # redelta when there are less than $var_redelta_threshold objects will be suppressed. @@ -363,12 +370,12 @@ if [ -n "$isminigc" ]; then rm -f .allowgc .needsgc remove_crud miniactive= - if [ -f .svnpack ] && is_svn_mirror; then + if [ -f .svnpack ] && [ -n "$svn_mirror" ]; then miniactive=1 progress "+ [$proj] mini garbage check (`date`)" make_svn_pack fi - if [ -z "$cfg_delay_gfi_redelta" ] && [ -f gfi-packs -a -s gfi-packs ] && is_gfi_mirror; then + if [ -z "$cfg_delay_gfi_redelta" ] && [ -n "$gfi_mirror" ]; then # $Girocco::Config::delay_gfi_redelta is false, force redeltification now if [ -z "$miniactive" ]; then miniactive=1 @@ -385,7 +392,7 @@ if [ -n "$isminigc" ]; then miniactive=1 progress "+ [$proj] mini garbage check (`date`)" fi - if [ -f gfi-packs -a -s gfi-packs ] && is_gfi_mirror; then + if [ -n "$gfi_mirror" ]; then repack_gfi_packs packcnt="$(list_packs --count $lpo objects/pack || :)" fi @@ -459,7 +466,7 @@ rm -f .allowgc remove_crud # Run 'git svn gc' now for svn mirrors -if is_svn_mirror; then +if [ -n "$svn_mirror" ]; then git svn gc || : fi @@ -498,7 +505,7 @@ progress "+ [$proj] garbage check (`date`)" newdeltas= [ -z "$alwaysredelta" ] || newdeltas=-f -if [ -z "$newdeltas" ] && [ -f gfi-packs -a -s gfi-packs ] && is_gfi_mirror; then +if [ -z "$newdeltas" ] && [ -n "$gfi_mirror" ]; then if [ $(list_packs --exclude-no-idx --count objects/pack) -le \ $(list_packs --exclude-no-idx --count --quiet --only gfi-packs) ]; then # Don't bother with repack_gfi_packs since everything's being repacked -- 2.11.4.GIT