fetch-pack: grow stateless RPC windows exponentially
When updating large repositories, the LARGE_FLUSH limit (that is, the limit at which the window growth strategy switches from exponential to linear) is reached quite quickly. Use a conservative exponential growth strategy when that limit is reached instead (and increase LARGE_FLUSH so that there is no regression in window size). This optimization is only applied during stateless RPCs to avoid the issue raised and fixed in commit 44d8dc54 (Fix potential local deadlock during fetch-pack, 2011-03-29). Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jonathan Tan committed
Jul 18, 2016 at 15:21 UTC
da470981defcace6e909b74ebc4ab5a40a702728
1 file changed
+12
-7
fetch-pack.c
+12
-7
@@ -243,16 +243,21 @@ static void insert_one_alternate_ref(const struct ref *ref, void *unused)
243
244
#define INITIAL_FLUSH 16
245
#define PIPESAFE_FLUSH 32
246
-#define LARGE_FLUSH 1024
246
+#define LARGE_FLUSH 16384
247
248
static int next_flush(struct fetch_pack_args *args, int count)
249
{
250
- int flush_limit = args->stateless_rpc ? LARGE_FLUSH : PIPESAFE_FLUSH;
251
-
252
- if (count < flush_limit)
253
- count <<= 1;
254
- else
255
- count += flush_limit;
250
+ if (args->stateless_rpc) {
251
+ if (count < LARGE_FLUSH)
252
+ count <<= 1;
253
+ else
254
+ count = count * 11 / 10;
255
+ } else {
256
+ if (count < PIPESAFE_FLUSH)
257
+ count <<= 1;
258
+ else
259
+ count += PIPESAFE_FLUSH;
260
+ }
261
return count;
262
}
263