fetch-pack: progressively use larger handshake windows
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Mar 2011 04:52:44 +0000 (21:52 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Mar 2011 04:53:25 +0000 (21:53 -0700)
The client has to dig the history deeper when more recent parts of its
history do not have any overlap with the server it is fetching from. Make
the handshake window exponentially larger as we dig deeper, with a
reasonable upper cap.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Shawn Pearce <spearce@spearce.org>
builtin/fetch-pack.c

index 1abe624dc8a850f63dfc814950c1aadab97e5fbb..b4f34a2cf93a8e0579ea183b644f558807df47e5 100644 (file)
@@ -219,10 +219,15 @@ static void send_request(int fd, struct strbuf *buf)
 }
 
 #define INITIAL_FLUSH 32
+#define LARGE_FLUSH 1024
 
 static int next_flush(int count)
 {
-       return INITIAL_FLUSH + count;
+       if (count < LARGE_FLUSH)
+               count <<= 1;
+       else
+               count += LARGE_FLUSH;
+       return count;
 }
 
 static int find_common(int fd[2], unsigned char *result_sha1,