git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 7/7] pack-objects: show some progress when counting kept objects

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Apr 14, 2018, 15:26 UTC
Message-ID
<20180414152642.4666-8-pclouds@gmail.com>
In-Reply-To
<20180414152642.4666-1-pclouds@gmail.com>

We only show progress when there are new objects to be packed. But when --keep-pack is specified on the base pack, we will exclude most of objects. This makes 'pack-objects' stay silent for a long time while the counting phase is going.

Let's show some progress whenever we visit an object instead. The old "Counting objects" is renamed to "Enumerating objects" and a new progress "Counting objects" line is added.

This new "Counting objects" line should progress pretty quick when the system is beefy. But when the system is under pressure, the reading object header done in this phase could be slow and showing progress is an improvement over staying silent in the current code.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index c77bea404d..6a1346c41f 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -46,7 +46,7 @@ static const char *pack_usage[] = {
 static struct packing_data to_pack;
 
 static struct pack_idx_entry **written_list;
-static uint32_t nr_result, nr_written;
+static uint32_t nr_result, nr_written, nr_seen;
 
 static int non_empty;
 static int reuse_delta = 1, reuse_object = 1;
@@ -1096,6 +1096,8 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
 	off_t found_offset = 0;
 	uint32_t index_pos;
 
+	display_progress(progress_state, ++nr_seen);
+
 	if (have_duplicate_entry(oid, exclude, &index_pos))
 		return 0;
 
@@ -1111,8 +1113,6 @@ static int add_object_entry(const struct object_id *oid, enum object_type type,
 	create_object_entry(oid, type, pack_name_hash(name),
 			    exclude, name && no_try_delta(name),
 			    index_pos, found_pack, found_offset);
-
-	display_progress(progress_state, nr_result);
 	return 1;
 }
 
@@ -1123,6 +1123,8 @@ static int add_object_entry_from_bitmap(const struct object_id *oid,
 {
 	uint32_t index_pos;
 
+	display_progress(progress_state, ++nr_seen);
+
 	if (have_duplicate_entry(oid, 0, &index_pos))
 		return 0;
 
@@ -1130,8 +1132,6 @@ static int add_object_entry_from_bitmap(const struct object_id *oid,
 		return 0;
 
 	create_object_entry(oid, type, name_hash, 0, 0, index_pos, pack, offset);
-
-	display_progress(progress_state, nr_result);
 	return 1;
 }
 
@@ -1716,6 +1716,10 @@ static void get_object_details(void)
 	uint32_t i;
 	struct object_entry **sorted_by_offset;
 
+	if (progress)
+		progress_state = start_progress(_("Counting objects"),
+						to_pack.nr_objects);
+
 	sorted_by_offset = xcalloc(to_pack.nr_objects, sizeof(struct object_entry *));
 	for (i = 0; i < to_pack.nr_objects; i++)
 		sorted_by_offset[i] = to_pack.objects + i;
@@ -1726,7 +1730,9 @@ static void get_object_details(void)
 		check_object(entry);
 		if (big_file_threshold < entry->size)
 			entry->no_try_delta = 1;
+		display_progress(progress_state, i + 1);
 	}
+	stop_progress(&progress_state);
 
 	/*
 	 * This must happen in a second pass, since we rely on the delta
@@ -3209,7 +3215,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 	}
 
 	if (progress)
-		progress_state = start_progress(_("Counting objects"), 0);
+		progress_state = start_progress(_("Enumerating objects"), 0);
 	if (!use_internal_rev_list)
 		read_object_list_from_stdin();
 	else {
-- 
2.17.0.367.g5dd2e386c3
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 4 of 19 in “nd/repack-keep-pack update”
  1. 0/7 nd/repack-keep-pack updateNguyễn Thái Ngọc Duy, Apr 14, 2018
  2. 3/7 gc: add --keep-largest-pack optionNguyễn Thái Ngọc Duy, Apr 14, 2018
  3. 2/7 repack: add --keep-pack optionNguyễn Thái Ngọc Duy, Apr 14, 2018
  4. 7/7 pack-objects: show some progress when counting kept objectsNguyễn Thái Ngọc Duy, Apr 14, 2018
  5. 5/7 gc: handle a corner case in gc.bigPackThresholdNguyễn Thái Ngọc Duy, Apr 14, 2018
  6. 6/7 gc --auto: exclude base pack if not enough mem to "repack -ad"Nguyễn Thái Ngọc Duy, Apr 14, 2018
  7. 4/7 gc: add gc.bigPackThreshold configNguyễn Thái Ngọc Duy, Apr 14, 2018
  8. 1/7 t7700: have closing quote of a test at the beginning of lineNguyễn Thái Ngọc Duy, Apr 14, 2018
  9. Ævar Arnfjörð BjarmasonApr 14, 2018
  10. Junio C HamanoApr 14, 2018
  11. 0/7 nd/repack-keep-pack updateNguyễn Thái Ngọc Duy, Apr 15, 2018
  12. 1/7 t7700: have closing quote of a test at the beginning of lineNguyễn Thái Ngọc Duy, Apr 15, 2018
  13. 2/7 repack: add --keep-pack optionNguyễn Thái Ngọc Duy, Apr 15, 2018
  14. 5/7 gc: handle a corner case in gc.bigPackThresholdNguyễn Thái Ngọc Duy, Apr 15, 2018
  15. 7/7 pack-objects: show some progress when counting kept objectsNguyễn Thái Ngọc Duy, Apr 15, 2018
  16. 6/7 gc --auto: exclude base pack if not enough mem to "repack -ad"Nguyễn Thái Ngọc Duy, Apr 15, 2018
  17. 3/7 gc: add --keep-largest-pack optionNguyễn Thái Ngọc Duy, Apr 15, 2018
  18. 4/7 gc: add gc.bigPackThreshold configNguyễn Thái Ngọc Duy, Apr 15, 2018
  19. Junio C HamanoApr 16, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.