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

Re: Re*: Extremely slow progress during 'git reflog expire --all'

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 7, 2010, 18:43 UTC
Message-ID
<7vk4sjcddh.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vochvcdkc.fsf_-_@alter.siamese.dyndns.org>
Side note.
It may be an improvement to dig the history even more incrementally.

Inside unreachable(), we currently dig immediately down to root, but it may give us a better performance in a long history with reflog entries that wildly jump everywhere in that history if we dug down to the timestamp of the commit we are looking at. A patch to do so on top of the previous one may look like this.

 builtin-reflog.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/builtin-reflog.c b/builtin-reflog.c
index 9792090..42d225f 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -274,16 +274,19 @@ static int unreachable(struct expire_reflog_cb *cb, struct commit *commit, unsig
 			return 0;
 	}
 
-	/* Reachable from the current ref?  Don't prune. */
-	if (commit->object.flags & REACHABLE)
-		return 0;
+	while (1) {
+		/* Reachable from the current ref?  Don't prune. */
+		if (commit->object.flags & REACHABLE)
+			return 0;
 
-	if (cb->mark_list && cb->mark_limit) {
-		cb->mark_limit = 0; /* dig down to the root */
+		/* Did we mark everything?  Then we know we cannot reach it. */
+		if (!cb->mark_list || !cb->mark_limit)
+			return 1;
+
+		/* Dig down to the timestamp of this commit, or down to root. */
+		cb->mark_limit = (cb->mark_limit < commit->date) ? 0 : commit->date;
 		mark_reachable(cb);
 	}
-
-	return !(commit->object.flags & REACHABLE);
 }
 
 static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
-- 
1.7.1.rc0.212.gbd88f
Previous: Junio C HamanoNext: Jeff King
Message 13 of 15 in “Extremely slow progress during 'git reflog expire --all'”
  1. Frans PopApr 2, 2010
  2. Jeff KingApr 2, 2010
  3. Frans PopApr 2, 2010
  4. Jeff KingApr 2, 2010
  5. Frans PopApr 3, 2010
  6. Jeff KingApr 3, 2010
  7. Jeff KingApr 3, 2010
  8. Junio C HamanoApr 4, 2010
  9. Jeff KingApr 5, 2010
  10. Junio C HamanoApr 5, 2010
  11. Jeff KingApr 6, 2010
  12. Re*: Extremely slow progress during 'git reflog expire --all'Junio C Hamano, Apr 7, 2010
  13. Junio C HamanoApr 7, 2010
  14. Jeff KingApr 8, 2010
  15. Jeff KingApr 8, 2010

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.