git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually
Date: Sat,  5 Nov 2011 17:33:32 +0700	[thread overview]
Message-ID: <1320489212-524-1-git-send-email-pclouds@gmail.com> (raw)


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 I hate it every single time git hangs because gc is activated.
 Opening another terminal is an option but I would lose all terminal
 settings I have on the current one (e.g. access to suspended vim
 sessions).

 I don't think gc_warn_* need their own config vars. Hopefully
 hardcoded offset is good enough.

 builtin/gc.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/builtin/gc.c b/builtin/gc.c
index 0498094..1f4555e 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -25,7 +25,9 @@ static const char * const builtin_gc_usage[] = {
 static int pack_refs = 1;
 static int aggressive_window = 250;
 static int gc_auto_threshold = 6700;
+static int gc_warn_auto_threshold = 6600;
 static int gc_auto_pack_limit = 50;
+static int gc_warn_auto_pack_limit = 45;
 static const char *prune_expire = "2.weeks.ago";
 
 #define MAX_ADD 10
@@ -50,10 +52,12 @@ static int gc_config(const char *var, const char *value, void *cb)
 	}
 	if (!strcmp(var, "gc.auto")) {
 		gc_auto_threshold = git_config_int(var, value);
+		gc_warn_auto_threshold = gc_auto_threshold - 100;
 		return 0;
 	}
 	if (!strcmp(var, "gc.autopacklimit")) {
 		gc_auto_pack_limit = git_config_int(var, value);
+		gc_warn_auto_pack_limit = gc_auto_pack_limit - 5;
 		return 0;
 	}
 	if (!strcmp(var, "gc.pruneexpire")) {
@@ -118,7 +122,13 @@ static int too_many_loose_objects(void)
 		}
 	}
 	closedir(dir);
-	return needed;
+	if (needed)
+		return 1;
+
+	auto_threshold = (gc_warn_auto_threshold + 255) / 256;
+	if (num_loose > auto_threshold)
+		warning(_("Too many loose objects. \"git gc\" will soon run automatically"));
+	return 0;
 }
 
 static int too_many_packs(void)
@@ -141,7 +151,12 @@ static int too_many_packs(void)
 		 */
 		cnt++;
 	}
-	return gc_auto_pack_limit <= cnt;
+	if (gc_auto_pack_limit <= cnt)
+		return 1;
+
+	if (gc_warn_auto_pack_limit <= cnt)
+		warning(_("Too many packs, \"git gc\" will soon run automatically."));
+	return 0;
 }
 
 static int need_to_gc(void)
-- 
1.7.4.74.g639db

             reply	other threads:[~2011-11-05 10:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-05 10:33 Nguyễn Thái Ngọc Duy [this message]
2011-11-05 13:39 ` [PATCH] Introduce gc.autowarnonly config option Fernando Vezzosi
2011-11-05 10:33   ` [PATCH 2/1] gc --auto: warn gc will soon run, give users a chance to run manually Fernando Vezzosi
2011-11-06  2:47     ` Nguyen Thai Ngoc Duy
2011-11-05 10:33   ` Fernando Vezzosi
2011-11-06  0:19     ` Junio C Hamano
2011-11-05 14:22   ` [PATCH] Introduce gc.autowarnonly config option Sverre Rabbelier
2011-11-07  0:18   ` Jay Soffian
2012-03-09 19:20   ` Sverre Rabbelier
2012-03-09 19:35     ` Junio C Hamano
2011-11-06 16:37 ` [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually Matthieu Moy
2011-11-07  6:04 ` Junio C Hamano
2011-11-07 10:55   ` Nguyen Thai Ngoc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320489212-524-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).