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

Re: [PATCH] revision.c: reduce object database queries

From
Jeff King <peff@peff.net>
Date
Feb 26, 2018, 01:38 UTC
Message-ID
<20180226013822.GA9385@sigill.intra.peff.net>
In-Reply-To
<20180226013048.GA8677@sigill.intra.peff.net>
On Sun, Feb 25, 2018 at 08:30:48PM -0500, Jeff King wrote:
Show 25 quoted lines
> > 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;
> 
> We don't actually need the object contents at all right here. This is
> just faking the "parsed" flag for later so that calls to parse_object()
> don't barf.
> 
> This code comes originally form 454fbbcde3 (git-rev-list: allow missing
> objects when the parent is marked UNINTERESTING, 2005-07-10). But later,
> in aeeae1b771 (revision traversal: allow UNINTERESTING objects to be
> missing, 2009-01-27), we marked dealt with calling parse_object() on the
> parents more directly.
> 
> So what I wonder is whether this code is simply redundant and can go
> away entirely. That would save the has_object_file() call in all cases.

There's a similar case for trees. In mark_tree_contents_uninteresting() we do:

   if (!has_object_file(&obj->oid))
	return;
   if (parse_tree(tree) < 0)
	die("bad tree %s", oid_to_hex(&obj->oid));
which seems wasteful. Probably this could be:
  if (parse_tree_gently(tree, 1) < 0)
	return; /* missing uninteresting trees ok */

though technically the existing code allows _missing_ trees, but not on corrupt ones.

I guess this is perhaps less interesting, because we only mark trees directly fed from the pending array, not every tree of commits that we traverse. Though if you had a really gigantic tree, it might be measurable.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 4 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.