{"thread":{"id":"28847","subject":"[PATCH] gc --auto: warn gc will soon run, give users a chance to run manually","startedAt":"2011-11-05T10:33:32Z","lastAt":"2011-11-07T10:55:53Z","messageCount":4,"participants":["Nguyễn Thái Ngọc Duy","Matthieu Moy","Junio C Hamano","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"178895","messageId":"1320489212-524-1-git-send-email-pclouds@gmail.com","threadId":"28847","inReplyTo":null,"subject":"[PATCH] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-05T10:33:32Z","receivedAt":"2011-11-05T10:33:32Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n I hate it every single time git hangs because gc is activated.\n Opening another terminal is an option but I would lose all terminal\n settings I have on the current one (e.g. access to suspended vim\n sessions).\n\n I don't think gc_warn_* need their own config vars. Hopefully\n hardcoded offset is good enough.\n\n builtin/gc.c |   19 +++++++++++++++++--\n 1 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex 0498094..1f4555e 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -25,7 +25,9 @@ static const char * const builtin_gc_usage[] = {\n static int pack_refs = 1;\n static int aggressive_window = 250;\n static int gc_auto_threshold = 6700;\n+static int gc_warn_auto_threshold = 6600;\n static int gc_auto_pack_limit = 50;\n+static int gc_warn_auto_pack_limit = 45;\n static const char *prune_expire = \"2.weeks.ago\";\n \n #define MAX_ADD 10\n@@ -50,10 +52,12 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!strcmp(var, \"gc.auto\")) {\n \t\tgc_auto_threshold = git_config_int(var, value);\n+\t\tgc_warn_auto_threshold = gc_auto_threshold - 100;\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.autopacklimit\")) {\n \t\tgc_auto_pack_limit = git_config_int(var, value);\n+\t\tgc_warn_auto_pack_limit = gc_auto_pack_limit - 5;\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"gc.pruneexpire\")) {\n@@ -118,7 +122,13 @@ static int too_many_loose_objects(void)\n \t\t}\n \t}\n \tclosedir(dir);\n-\treturn needed;\n+\tif (needed)\n+\t\treturn 1;\n+\n+\tauto_threshold = (gc_warn_auto_threshold + 255) / 256;\n+\tif (num_loose > auto_threshold)\n+\t\twarning(_(\"Too many loose objects. \\\"git gc\\\" will soon run automatically\"));\n+\treturn 0;\n }\n \n static int too_many_packs(void)\n@@ -141,7 +151,12 @@ static int too_many_packs(void)\n \t\t */\n \t\tcnt++;\n \t}\n-\treturn gc_auto_pack_limit <= cnt;\n+\tif (gc_auto_pack_limit <= cnt)\n+\t\treturn 1;\n+\n+\tif (gc_warn_auto_pack_limit <= cnt)\n+\t\twarning(_(\"Too many packs, \\\"git gc\\\" will soon run automatically.\"));\n+\treturn 0;\n }\n \n static int need_to_gc(void)\n-- \n1.7.4.74.g639db\n"},{"id":"178968","messageId":"vpqk47dus0e.fsf@bauges.imag.fr","threadId":"28847","inReplyTo":"1320489212-524-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-11-06T16:37:05Z","receivedAt":"2011-11-06T16:37:05Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> +\t\twarning(_(\"Too many loose objects. \\\"git gc\\\" will soon run automatically\"));\n[...]\n> +\t\twarning(_(\"Too many packs, \\\"git gc\\\" will soon run automatically.\"));\n\nNit: you have a period in the second message, but not for the first.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"179005","messageId":"7vfwi031ts.fsf@alter.siamese.dyndns.org","threadId":"28847","inReplyTo":"1320489212-524-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-07T06:04:47Z","receivedAt":"2011-11-07T06:04:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  I hate it every single time git hangs because gc is activated.\n>  Opening another terminal is an option but I would lose all terminal\n>  settings I have on the current one (e.g. access to suspended vim\n>  sessions).\n>\n>  I don't think gc_warn_* need their own config vars. Hopefully\n>  hardcoded offset is good enough.\n\nLet's think about How the user chooses a custom value for the threshold\n(or accepts that the default threshold value 6600 is good enough).\n\nIn order to minimize the time the user has to endure when the eventual\nauto-gc kicks in, the value needs to be small enough, and to minimize the\nfrequency the auto-gc kicks in, the value needs to be large enough. It is\na balancing act between the two.\n\nSlower users (those who do not create that many objects within a given\ntime period) can afford to have a small threashold and do not have to\nsuffer too frequent auto-gc. Busier ones would rather choose larger\nthreashold to avoid frequent auto-gc because they create many objects\nwithin a given time period.\n\nThe reason why the user would want a warning is probably because the user\nsometimes is too busy and cannot afford the disruption of auto-gc, but the\nbusy period luckily does not last indefinitely, e.g. if a warning is given\ntwo days before the auto-gc actually kicks in, then within that two days\nthere is a window of time that the user can manually run gc while fetching\na cup of coffee. For different users, the \"two days\" in this example would\nbe different. Some people would need longer warning period. Some people\ncan live with shorter warning period. The number of objects before the\nnext auto-gc run, divided by the number of objects the user would create\non average in an hour, would give the length of the warning period.\n\nNow, I suspect that busier users would need longer window than slower\nones, which leads me to suspect that a good default would not be a\nhardcoded constant offset (e.g. once you see the new warning, the auto-gc\nkicks in after creating 100 objects) but some ratio of the threshold\n(e.g. you have 2% margin after getting a warning before the auto-gc kicks\nin).\n"},{"id":"179024","messageId":"CACsJy8DytH+2WcSpxFYWOR-chgorumzDawYyY1S+MKKDzRa6zw@mail.gmail.com","threadId":"28847","inReplyTo":"7vfwi031ts.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] gc --auto: warn gc will soon run, give users a chance to run manually","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-11-07T10:55:53Z","receivedAt":"2011-11-07T10:55:53Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2011/11/7 Junio C Hamano <gitster@pobox.com>:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>>  I hate it every single time git hangs because gc is activated.\n>>  Opening another terminal is an option but I would lose all terminal\n>>  settings I have on the current one (e.g. access to suspended vim\n>>  sessions).\n>>\n>>  I don't think gc_warn_* need their own config vars. Hopefully\n>>  hardcoded offset is good enough.\n>\n> Let's think about How the user chooses a custom value for the threshold\n> (or accepts that the default threshold value 6600 is good enough).\n>\n> ...\n>\n> Now, I suspect that busier users would need longer window than slower\n> ones, which leads me to suspect that a good default would not be a\n> hardcoded constant offset (e.g. once you see the new warning, the auto-gc\n> kicks in after creating 100 objects) but some ratio of the threshold\n> (e.g. you have 2% margin after getting a warning before the auto-gc kicks\n> in).\n\nSpeaking for myself, as soon as I see the warning, I would immediately\nstart a new shell for git-gc alone and get back to my work (hopefully\ngc will not be activated again while another gc is running) so one or\nmaybe three warnings may be enough. But yes, some ratio may be better\nfor different users.\n-- \nDuy\n"}]}