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

[PATCH] revision.c: reduce object database queries

From
Derrick Stolee <dstolee@microsoft.com>
Date
Feb 25, 2018, 01:34 UTC
Message-ID
<1519522496-73090-1-git-send-email-dstolee@microsoft.com>

In mark_parents_uninteresting(), we check for the existence of an object file to see if we should treat a commit as parsed. The result is to set the "parsed" bit on the commit.

Modify the condition to only check has_object_file() if the result would change the parsed bit.

When a local branch is different from its upstream ref, "git status" will compute ahead/behind counts. This uses paint_down_to_common() and hits mark_parents_uninteresting(). On a copy of the Linux repo with a local instance of "master" behind the remote branch "origin/master" by ~60,000 commits, we find the performance of "git status" went from 1.42 seconds to 1.32 seconds, for a relative difference of -7.0%.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
---
 revision.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/revision.c b/revision.c
index 5ce9b93..bc7def5 100644
--- a/revision.c
+++ b/revision.c
@@ -113,7 +113,8 @@ void mark_parents_uninteresting(struct commit *commit)
 			 * it is popped next time around, we won't be trying
 			 * to parse it and get an error.
 			 */
-			if (!has_object_file(&commit->object.oid))
+			if (!commit->object.parsed &&
+			    !has_object_file(&commit->object.oid))
 				commit->object.parsed = 1;
 
 			if (commit->object.flags & UNINTERESTING)
-- 
2.7.4
Next: Derrick Stolee
Message 1 of 7 in “revision.c: reduce object database queries”
  1. revision.c: reduce object database queriesDerrick Stolee, Feb 25, 2018
  2. Derrick StoleeFeb 25, 2018
  3. Jeff KingFeb 26, 2018
  4. Jeff KingFeb 26, 2018
  5. Junio C HamanoFeb 27, 2018
  6. Jeff KingFeb 28, 2018
  7. Derrick StoleeFeb 28, 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.