diff mbox series

[10/14] pack-objects: add trace2 regions

Message ID 1aa79cb126ec43dae1c01d3ce740d9b687d69517.1548192131.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Trace2 tracing facility | expand

Commit Message

Derrick Stolee via GitGitGadget Jan. 22, 2019, 9:22 p.m. UTC
From: Derrick Stolee <dstolee@microsoft.com>

When studying the performance of 'git push' we would like to know
how much time is spent at various parts of the command. One area
that could cause performance trouble is 'git pack-objects'.

Add trace2 regions around the three main actions taken in this
command:

1. Enumerate objects.
2. Prepare pack.
3. Write pack-file.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 builtin/pack-objects.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Derrick Stolee Jan. 23, 2019, 1:19 a.m. UTC | #1
On 1/22/2019 4:22 PM, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <dstolee@microsoft.com>
>
> When studying the performance of 'git push' we would like to know
> how much time is spent at various parts of the command. One area
> that could cause performance trouble is 'git pack-objects'.
>
> Add trace2 regions around the three main actions taken in this
> command:
>
> 1. Enumerate objects.
> 2. Prepare pack.
> 3. Write pack-file.
>
> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>

We've had this patch in our private branch for a while, and is how we 
discovered the need for the sparse push algorithm [1]. We will use it to 
measure it's effectiveness as new Microsoft users onboard to the new 
algorithm.

Thanks,

-Stolee

[1] https://public-inbox.org/git/pull.89.v5.git.gitgitgadget@gmail.com/
diff mbox series

Patch

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 889df2c755..6708529e3c 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -33,6 +33,7 @@ 
 #include "object-store.h"
 #include "dir.h"
 #include "midx.h"
+#include "trace2.h"
 
 #define IN_PACK(obj) oe_in_pack(&to_pack, obj)
 #define SIZE(obj) oe_size(&to_pack, obj)
@@ -3472,6 +3473,7 @@  int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		}
 	}
 
+	trace2_region_enter("pack-objects", "enumerate-objects", the_repository);
 	prepare_packing_data(the_repository, &to_pack);
 
 	if (progress)
@@ -3486,12 +3488,20 @@  int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	if (include_tag && nr_result)
 		for_each_ref(add_ref_tag, NULL);
 	stop_progress(&progress_state);
+	trace2_region_leave("pack-objects", "enumerate-objects", the_repository);
 
 	if (non_empty && !nr_result)
 		return 0;
-	if (nr_result)
+	if (nr_result) {
+		trace2_region_enter("pack-objects", "prepare-pack", the_repository);
 		prepare_pack(window, depth);
+		trace2_region_leave("pack-objects", "prepare-pack", the_repository);
+	}
+
+	trace2_region_enter("pack-objects", "write-pack-file", the_repository);
 	write_pack_file();
+	trace2_region_leave("pack-objects", "write-pack-file", the_repository);
+
 	if (progress)
 		fprintf_ln(stderr,
 			   _("Total %"PRIu32" (delta %"PRIu32"),"