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

Re: No progress from push when using bitmaps

From
Jeff King <peff@peff.net>
Date
Mar 13, 2014, 22:24 UTC
Message-ID
<20140313222428.GA18406@sigill.intra.peff.net>
In-Reply-To
<20140313220754.GA20173@sigill.intra.peff.net>
On Thu, Mar 13, 2014 at 06:07:54PM -0400, Jeff King wrote:
>   3. Use the regular "Writing objects" progress, but fake the object
>      count. We know we are writing M bytes with N objects. Bump the
>      counter by 1 for every M/N bytes we write.

Here is that strategy. I think it looks pretty nice, and it seamlessly handles the case where you have extra objects to send on top of the reused pack (we just keep the same progress meter counting up).

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 831dd05..f187859 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -709,7 +709,7 @@ static struct object_entry **compute_write_order(void)
 static off_t write_reused_pack(struct sha1file *f)
 {
 	unsigned char buffer[8192];
-	off_t to_write;
+	off_t to_write, total;
 	int fd;
 
 	if (!is_pack_valid(reuse_packfile))
@@ -726,7 +726,7 @@ static off_t write_reused_pack(struct sha1file *f)
 	if (reuse_packfile_offset < 0)
 		reuse_packfile_offset = reuse_packfile->pack_size - 20;
 
-	to_write = reuse_packfile_offset - sizeof(struct pack_header);
+	total = to_write = reuse_packfile_offset - sizeof(struct pack_header);
 
 	while (to_write) {
 		int read_pack = xread(fd, buffer, sizeof(buffer));
@@ -739,10 +739,23 @@ static off_t write_reused_pack(struct sha1file *f)
 
 		sha1write(f, buffer, read_pack);
 		to_write -= read_pack;
+
+		/*
+		 * We don't know the actual number of objects written,
+		 * only how many bytes written, how many bytes total, and
+		 * how many objects total. So we can fake it by pretending all
+		 * objects we are writing are the same size. This gives us a
+		 * smooth progress meter, and at the end it matches the true
+		 * answer.
+		 */
+		written = reuse_packfile_objects *
+				(((double)(total - to_write)) / total);
+		display_progress(progress_state, written);
 	}
 
 	close(fd);
-	written += reuse_packfile_objects;
+	written = reuse_packfile_objects;
+	display_progress(progress_state, written);
 	return reuse_packfile_offset - sizeof(struct pack_header);
 }
 
Previous: Junio C HamanoNext: Michael Haggerty
Message 6 of 10 in “No progress from push when using bitmaps”
  1. Shawn PearceMar 13, 2014
  2. Jeff KingMar 13, 2014
  3. Shawn PearceMar 13, 2014
  4. Jeff KingMar 13, 2014
  5. Junio C HamanoMar 13, 2014
  6. Jeff KingMar 13, 2014
  7. Michael HaggertyMar 14, 2014
  8. Duy NguyenMar 14, 2014
  9. Jeff KingMar 14, 2014
  10. Duy NguyenMar 14, 2014

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.