{"thread":{"id":"26780","subject":"[PATCH 1/3] fetch-pack: factor out hardcoded handshake window size","startedAt":"2011-03-18T22:26:58Z","lastAt":"2011-03-18T22:26:58Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"163685","messageId":"7v7hbwt68d.fsf@alter.siamese.dyndns.org","threadId":"26780","inReplyTo":null,"subject":"[PATCH 1/3] fetch-pack: factor out hardcoded handshake window size","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-03-18T22:26:58Z","receivedAt":"2011-03-18T22:26:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The \"git fetch\" client presents the most recent 32 commits it has to the\nserver and gives a chance to the server to say \"ok, we heard enough\", and\ncontinues reporting what it has in chunks of 32 commits, digging its\nhistory down to older commits.\n\nMove the hardcoded size of the handshake window outside the code, so that\nwe can tweak it more easily.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I don't want to be stepping on your toes, but the first step was very\n   trivial.  Goes on top of the sp/maint-fetch-pack-stop-early topic.\n\n builtin/fetch-pack.c |   14 +++++++++++---\n 1 files changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 59fbda5..20e30f5 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -218,11 +218,18 @@ static void send_request(int fd, struct strbuf *buf)\n \t\tsafe_write(fd, buf->buf, buf->len);\n }\n \n+#define INITIAL_FLUSH 32\n+\n+static int next_flush(int count)\n+{\n+\treturn INITIAL_FLUSH + count;\n+}\n+\n static int find_common(int fd[2], unsigned char *result_sha1,\n \t\t       struct ref *refs)\n {\n \tint fetching;\n-\tint count = 0, flushes = 0, retval;\n+\tint count = 0, flushes = 0, flush_at = INITIAL_FLUSH, retval;\n \tconst unsigned char *sha1;\n \tunsigned in_vain = 0;\n \tint got_continue = 0;\n@@ -335,19 +342,20 @@ static int find_common(int fd[2], unsigned char *result_sha1,\n \t\tif (args.verbose)\n \t\t\tfprintf(stderr, \"have %s\\n\", sha1_to_hex(sha1));\n \t\tin_vain++;\n-\t\tif (!(31 & ++count)) {\n+\t\tif (flush_at <= ++count) {\n \t\t\tint ack;\n \n \t\t\tpacket_buf_flush(&req_buf);\n \t\t\tsend_request(fd[1], &req_buf);\n \t\t\tstrbuf_setlen(&req_buf, state_len);\n \t\t\tflushes++;\n+\t\t\tflush_at = next_flush(count);\n \n \t\t\t/*\n \t\t\t * We keep one window \"ahead\" of the other side, and\n \t\t\t * will wait for an ACK only on the next one\n \t\t\t */\n-\t\t\tif (!args.stateless_rpc && count == 32)\n+\t\t\tif (!args.stateless_rpc && count == INITIAL_FLUSH)\n \t\t\t\tcontinue;\n \n \t\t\tconsume_shallow_list(fd[0]);\n-- \n1.7.4.1.496.ga3201\n"}]}