@@ -323,6 +323,7 @@ static int find_common(struct fetch_negotiator *negotiator,
323
323
{
324
324
int fetching ;
325
325
int count = 0 , flushes = 0 , flush_at = INITIAL_FLUSH , retval ;
326
+ int negotiation_round = 0 , haves = 0 ;
326
327
const struct object_id * oid ;
327
328
unsigned in_vain = 0 ;
328
329
int got_continue = 0 ;
@@ -461,9 +462,19 @@ static int find_common(struct fetch_negotiator *negotiator,
461
462
packet_buf_write (& req_buf , "have %s\n" , oid_to_hex (oid ));
462
463
print_verbose (args , "have %s" , oid_to_hex (oid ));
463
464
in_vain ++ ;
465
+ haves ++ ;
464
466
if (flush_at <= ++ count ) {
465
467
int ack ;
466
468
469
+ negotiation_round ++ ;
470
+ trace2_region_enter_printf ("negotiation_v0_v1" , "round" ,
471
+ the_repository , "%d" ,
472
+ negotiation_round );
473
+ trace2_data_intmax ("negotiation_v0_v1" , the_repository ,
474
+ "haves_added" , haves );
475
+ trace2_data_intmax ("negotiation_v0_v1" , the_repository ,
476
+ "in_vain" , in_vain );
477
+ haves = 0 ;
467
478
packet_buf_flush (& req_buf );
468
479
send_request (args , fd [1 ], & req_buf );
469
480
strbuf_setlen (& req_buf , state_len );
@@ -485,6 +496,9 @@ static int find_common(struct fetch_negotiator *negotiator,
485
496
ack , oid_to_hex (result_oid ));
486
497
switch (ack ) {
487
498
case ACK :
499
+ trace2_region_leave_printf ("negotiation_v0_v1" , "round" ,
500
+ the_repository , "%d" ,
501
+ negotiation_round );
488
502
flushes = 0 ;
489
503
multi_ack = 0 ;
490
504
retval = 0 ;
@@ -510,6 +524,7 @@ static int find_common(struct fetch_negotiator *negotiator,
510
524
const char * hex = oid_to_hex (result_oid );
511
525
packet_buf_write (& req_buf , "have %s\n" , hex );
512
526
state_len = req_buf .len ;
527
+ haves ++ ;
513
528
/*
514
529
* Reset in_vain because an ack
515
530
* for this commit has not been
@@ -528,6 +543,9 @@ static int find_common(struct fetch_negotiator *negotiator,
528
543
}
529
544
} while (ack );
530
545
flushes -- ;
546
+ trace2_region_leave_printf ("negotiation_v0_v1" , "round" ,
547
+ the_repository , "%d" ,
548
+ negotiation_round );
531
549
if (got_continue && MAX_IN_VAIN < in_vain ) {
532
550
print_verbose (args , _ ("giving up" ));
533
551
break ; /* give up */
@@ -538,6 +556,8 @@ static int find_common(struct fetch_negotiator *negotiator,
538
556
}
539
557
done :
540
558
trace2_region_leave ("fetch-pack" , "negotiation_v0_v1" , the_repository );
559
+ trace2_data_intmax ("negotiation_v0_v1" , the_repository , "total_rounds" ,
560
+ negotiation_round );
541
561
if (!got_ready || !no_done ) {
542
562
packet_buf_write (& req_buf , "done\n" );
543
563
send_request (args , fd [1 ], & req_buf );
@@ -1381,6 +1401,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
1381
1401
1382
1402
haves_added = add_haves (negotiator , & req_buf , haves_to_send );
1383
1403
* in_vain += haves_added ;
1404
+ trace2_data_intmax ("negotiation_v2" , the_repository , "haves_added" , haves_added );
1405
+ trace2_data_intmax ("negotiation_v2" , the_repository , "in_vain" , * in_vain );
1384
1406
if (!haves_added || (seen_ack && * in_vain >= MAX_IN_VAIN )) {
1385
1407
/* Send Done */
1386
1408
packet_buf_write (& req_buf , "done\n" );
@@ -1623,6 +1645,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1623
1645
struct oidset common = OIDSET_INIT ;
1624
1646
struct packet_reader reader ;
1625
1647
int in_vain = 0 , negotiation_started = 0 ;
1648
+ int negotiation_round = 0 ;
1626
1649
int haves_to_send = INITIAL_FLUSH ;
1627
1650
struct fetch_negotiator negotiator_alloc ;
1628
1651
struct fetch_negotiator * negotiator ;
@@ -1679,12 +1702,20 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1679
1702
"negotiation_v2" ,
1680
1703
the_repository );
1681
1704
}
1705
+ negotiation_round ++ ;
1706
+ trace2_region_enter_printf ("negotiation_v2" , "round" ,
1707
+ the_repository , "%d" ,
1708
+ negotiation_round );
1682
1709
if (send_fetch_request (negotiator , fd [1 ], args , ref ,
1683
1710
& common ,
1684
1711
& haves_to_send , & in_vain ,
1685
1712
reader .use_sideband ,
1686
- seen_ack ))
1713
+ seen_ack )) {
1714
+ trace2_region_leave_printf ("negotiation_v2" , "round" ,
1715
+ the_repository , "%d" ,
1716
+ negotiation_round );
1687
1717
state = FETCH_GET_PACK ;
1718
+ }
1688
1719
else
1689
1720
state = FETCH_PROCESS_ACKS ;
1690
1721
break ;
@@ -1697,6 +1728,9 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1697
1728
seen_ack = 1 ;
1698
1729
oidset_insert (& common , & common_oid );
1699
1730
}
1731
+ trace2_region_leave_printf ("negotiation_v2" , "round" ,
1732
+ the_repository , "%d" ,
1733
+ negotiation_round );
1700
1734
if (received_ready ) {
1701
1735
/*
1702
1736
* Don't check for response delimiter; get_pack() will
@@ -1712,6 +1746,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
1712
1746
trace2_region_leave ("fetch-pack" ,
1713
1747
"negotiation_v2" ,
1714
1748
the_repository );
1749
+ trace2_data_intmax ("negotiation_v2" , the_repository ,
1750
+ "total_rounds" , negotiation_round );
1715
1751
/* Check for shallow-info section */
1716
1752
if (process_section_header (& reader , "shallow-info" , 1 ))
1717
1753
receive_shallow_info (args , & reader , shallows , si );
@@ -2091,6 +2127,7 @@ void negotiate_using_fetch(const struct oid_array *negotiation_tips,
2091
2127
int in_vain = 0 ;
2092
2128
int seen_ack = 0 ;
2093
2129
int last_iteration = 0 ;
2130
+ int negotiation_round = 0 ;
2094
2131
timestamp_t min_generation = GENERATION_NUMBER_INFINITY ;
2095
2132
2096
2133
fetch_negotiator_init (the_repository , & negotiator );
@@ -2104,11 +2141,17 @@ void negotiate_using_fetch(const struct oid_array *negotiation_tips,
2104
2141
add_to_object_array ,
2105
2142
& nt_object_array );
2106
2143
2144
+ trace2_region_enter ("fetch-pack" , "negotiate_using_fetch" , the_repository );
2107
2145
while (!last_iteration ) {
2108
2146
int haves_added ;
2109
2147
struct object_id common_oid ;
2110
2148
int received_ready = 0 ;
2111
2149
2150
+ negotiation_round ++ ;
2151
+
2152
+ trace2_region_enter_printf ("negotiate_using_fetch" , "round" ,
2153
+ the_repository , "%d" ,
2154
+ negotiation_round );
2112
2155
strbuf_reset (& req_buf );
2113
2156
write_fetch_command_and_capabilities (& req_buf , server_options );
2114
2157
@@ -2119,6 +2162,11 @@ void negotiate_using_fetch(const struct oid_array *negotiation_tips,
2119
2162
if (!haves_added || (seen_ack && in_vain >= MAX_IN_VAIN ))
2120
2163
last_iteration = 1 ;
2121
2164
2165
+ trace2_data_intmax ("negotiate_using_fetch" , the_repository ,
2166
+ "haves_added" , haves_added );
2167
+ trace2_data_intmax ("negotiate_using_fetch" , the_repository ,
2168
+ "in_vain" , in_vain );
2169
+
2122
2170
/* Send request */
2123
2171
packet_buf_flush (& req_buf );
2124
2172
if (write_in_full (fd [1 ], req_buf .buf , req_buf .len ) < 0 )
@@ -2151,7 +2199,13 @@ void negotiate_using_fetch(const struct oid_array *negotiation_tips,
2151
2199
REACH_SCRATCH , 0 ,
2152
2200
min_generation ))
2153
2201
last_iteration = 1 ;
2202
+ trace2_region_leave_printf ("negotiation" , "round" ,
2203
+ the_repository , "%d" ,
2204
+ negotiation_round );
2154
2205
}
2206
+ trace2_region_enter ("fetch-pack" , "negotiate_using_fetch" , the_repository );
2207
+ trace2_data_intmax ("negotiate_using_fetch" , the_repository ,
2208
+ "total_rounds" , negotiation_round );
2155
2209
clear_common_flag (acked_commits );
2156
2210
strbuf_release (& req_buf );
2157
2211
}
0 commit comments