From a21e6adf900332ff6a98f4f9293901cfb6185df5 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 18 Jun 2017 11:07:46 -0700 Subject: [PATCH] config: prefer core.compression=5 When initializing a new repository or updating a repository's config, prefer to set a core.compression value of 5 (leaving an existing valid but different value alone on config update). There are two reasons for this: 1) If left unset the defaults for core.compression and core.looseCompression differ. That implies potentially wasteful recompression may take place when packing loose objects into packs. 2) The default value (-1) which specifies the zlib default (which is currently 6) does not provide the best tradeoff. Number (1) could be corrected simply by setting a core.compression value of -1 which would provide a core.looseCompression default and levels would then match and (1) would go away. However, it turns out that the speed difference between levels 4 and 5 is generally somewhat less than the speed difference between levels 5 and 6 (the zlib default) while the space savings between levels 4 and 5 is generally double the space savings between levels 5 and 6. This may not be the case generally but seems to be the case when dealing with Git objects. In other words, level 5 is the inflection point of the graph, not 6. Thus level 5 provides the better speed, space and time tradeoff than level 6 does. Make it so. Signed-off-by: Kyle J. McKay --- Girocco/Project.pm | 2 ++ jailsetup.sh | 1 + toolbox/update-all-config.sh | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/Girocco/Project.pm b/Girocco/Project.pm index eaa5de9..13f8c3c 100644 --- a/Girocco/Project.pm +++ b/Girocco/Project.pm @@ -883,6 +883,8 @@ sub _setup { } # hooks never world writable chmod 02775, $self->{path}."/hooks" or die "chmod 02775 $self->{path}/hooks failed: $!"; + system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'core.compression', '5') == 0 + or die "setting core.compression failed: $?"; system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'core.logAllRefUpdates', 'false') == 0 or die "disabling core.logAllRefUpdates failed: $?"; system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', 'core.ignoreCase', 'false') == 0 diff --git a/jailsetup.sh b/jailsetup.sh index 3e7387c..0c1a726 100755 --- a/jailsetup.sh +++ b/jailsetup.sh @@ -177,6 +177,7 @@ if [ -n "$cfg_jgit_compatible_bitmaps" ]; then else update_config_item pack.writeBitmapHashCache true 1 fi +update_config_item core.compression 5 update_config_item http.lowSpeedLimit 1 update_config_item http.lowSpeedTime 600 update_config_item receive.maxInputSize "${cfg_max_receive_size:-0}" 1 diff --git a/toolbox/update-all-config.sh b/toolbox/update-all-config.sh index 5a8bf5a..4a185d9 100755 --- a/toolbox/update-all-config.sh +++ b/toolbox/update-all-config.sh @@ -279,6 +279,19 @@ eval "$cmd" | \ [ -z "$bad" ] || continue [ -n "$dryrun" ] || change_fperm config readconfiglist + cmplvl="$(configitem core.compression || :)" + case "$cmplvl" in + "5"|"") + ;; + "-1"|"0"|"1"|"2"|"3"|"4"|"6"|"7"|"8"|"9") + pmsg "WARNING: suboptimal core.compression value left unchanged: \"$cmplvl\"" + ;; + *) + pmsg "WARNING: replacing invalid core.compression value" + cmplvl= + ;; + esac + [ -n "$cmplvl" ] || do_config core.compression 5 grpshr="$(configitem core.sharedrepository || :)" if [ -z "$grpshr" ] || isboolfalse "$grpshr"; then do_config core.sharedrepository 1 -- 2.11.4.GIT