]> source.dussan.org Git - jgit.git/commitdiff
Measure time taken for negotiation in protocol V2 85/168985/7
authorAlexa Panfil <alexapizza@google.com>
Fri, 11 Sep 2020 09:34:23 +0000 (09:34 +0000)
committerAlexa Panfil <alexapizza@google.com>
Tue, 22 Sep 2020 10:05:03 +0000 (10:05 +0000)
Reason why this change is needed:
Getting this metric will help estimate how much time is spent
on negotiation in fetch V2.

What this patch does:
Measure time spent on negotiation rounds in UploadPack.fetchV2()
and save it in an instance of PackStatistics.Accumulator.
This is the same way the statistics are already gathered for
protocol V0/V1.

Change-Id: I14e55dd6ff743cb0b21b4953b533269ef069abb1

org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java

index 988901526168436f92c8e7a441323c0b34fda67d..8c243d439b5a7820522f6daf3c2f63f367b20f37 100644 (file)
@@ -1137,6 +1137,9 @@ public class UploadPack {
                        advertised = refIdSet(getAdvertisedOrDefaultRefs().values());
                }
 
+               PackStatistics.Accumulator accumulator = new PackStatistics.Accumulator();
+               long negotiateStart = System.currentTimeMillis();
+
                ProtocolV2Parser parser = new ProtocolV2Parser(transferConfig);
                FetchV2Request req = parser.parseFetchRequest(pckIn);
                currentRequest = req;
@@ -1238,7 +1241,11 @@ public class UploadPack {
                                // But sideband-all is not used, so we have to write it ourselves.
                                pckOut.writeString("packfile\n"); //$NON-NLS-1$
                        }
-                       sendPack(new PackStatistics.Accumulator(),
+
+                       accumulator.timeNegotiating = System.currentTimeMillis()
+                                       - negotiateStart;
+
+                       sendPack(accumulator,
                                        req,
                                        req.getClientCapabilities().contains(OPTION_INCLUDE_TAG)
                                                ? db.getRefDatabase().getRefsByPrefix(R_TAGS)