{"thread":{"id":"52289","subject":"[PATCH] builtin/unpack-objects.c: show throughput progress","startedAt":"2019-11-19T01:25:39Z","lastAt":"2019-11-19T01:25:39Z","messageCount":1,"participants":["SZEDER Gábor"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"386494","messageId":"20191119012525.10455-1-szeder.dev@gmail.com","threadId":"52289","inReplyTo":null,"subject":"[PATCH] builtin/unpack-objects.c: show throughput progress","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2019-11-19T01:25:25Z","receivedAt":"2019-11-19T01:25:39Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"'git unpack-objects' shows a progress line only counting the number of\nunpacked objects, so if some of the received objects are unusually\nlarge, then that progress might appear to be frozen while processing\nsuch a larger object.  I just stared at a seemingly stuck progress\nline for over half a minute, while 'git fetch' was busy receiving a\npack with only a couple of objects (i.e. fewer than\n'fetch.unpackLimit'), with one of them being over 80MB.\n\nDisplay throughput in 'git unpack-objects' progress line, so we show\nthat something is going on even when receiving and processing a large\nobject.\n\nCounting the consumed bytes is far away from the place that\ncounts objects and displays progress, and to pass around the 'struct\nprogress' instance we would have to modify the signature of five\nfunctions and 14 of their callsites: this is just too much churn, so\nlet's rather make it file-scope static.\n\n'git index-pack', i.e. the non-unpacking cousin of 'git\nunpack-objects' already includes throughput in its progress line, and\nit uses a file-scope static 'struct progress' instance as well.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n builtin/unpack-objects.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex a87a4bfd2c..9100964667 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -24,6 +24,7 @@ static off_t consumed_bytes;\n static off_t max_input_size;\n static git_hash_ctx ctx;\n static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT;\n+static struct progress *progress;\n \n /*\n  * When running under --strict mode, objects whose reachability are\n@@ -92,6 +93,7 @@ static void use(int bytes)\n \tconsumed_bytes += bytes;\n \tif (max_input_size && consumed_bytes > max_input_size)\n \t\tdie(_(\"pack exceeds maximum allowed size\"));\n+\tdisplay_throughput(progress, consumed_bytes);\n }\n \n static void *get_data(unsigned long size)\n@@ -484,7 +486,6 @@ static void unpack_one(unsigned nr)\n static void unpack_all(void)\n {\n \tint i;\n-\tstruct progress *progress = NULL;\n \tstruct pack_header *hdr = fill(sizeof(struct pack_header));\n \n \tnr_objects = ntohl(hdr->hdr_entries);\n-- \n2.24.0.388.gde53c094ea\n\n"}]}