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

Re: [PATCH 9/9] upload-pack: free tree buffers after parsing

From
Patrick Steinhardt <ps@pks.im>
Date
Mar 4, 2024, 10:00 UTC
Message-ID
<ZeWbsVL0NF32rYAt@tanuki>
In-Reply-To
<20240304095736.GA3723539@coredump.intra.peff.net>
On Mon, Mar 04, 2024 at 04:57:36AM -0500, Jeff King wrote:
Show 37 quoted lines
> On Mon, Mar 04, 2024 at 09:33:57AM +0100, Patrick Steinhardt wrote:
> 
> > > +	if (skip_hash && discard_tree &&
> > > +	    (!obj || obj->type == OBJ_TREE) &&
> > > +	    oid_object_info(r, oid, NULL) == OBJ_TREE) {
> > > +		return &lookup_tree(r, oid)->object;
> > > +	}
> > 
> > The other condition for blobs does the same, but the condition here
> > confuses me. Why do we call `oid_object_info()` if we have already
> > figured out that `obj->type == OBJ_TREE`? Feels like wasted effort if
> > the in-memory object has been determined to be a tree already anyway.
> > 
> > I'd rather have expected it to look like the following:
> > 
> > if (skip_hash && discard_tree &&
> >     ((obj && obj->type == OBJ_TREE) ||
> >      (!obj && oid_object_info(r, oid, NULL)) == OBJ_TREE)) {
> > 		return &lookup_tree(r, oid)->object;
> > }
> > 
> > Am I missing some side effect that `oid_object_info()` provides?
> 
> Calling oid_object_info() will make sure the on-disk object exists and
> has the expected type. Keep in mind that an in-memory "struct object"
> may have a type that was just implied by another reference. E.g., if a
> commit references some object X in its tree field, then we'll call
> lookup_tree(X) to get a "struct tree" without actually touching the odb
> at all. When it comes time to parse that object, that's when we'll see
> if we really have it and if it's a tree.
> 
> In the case of skip_hash (and discard_tree) it might be OK to skip both
> of those checks. If we do, I think we should probably do the same for
> blobs (in the skip_hash case, we could just return the object we found
> already).
> 
> But I'd definitely prefer to do that as a separate step (if at all).
Thanks for the explanation!
Patrick
Previous: Jeff KingNext: Junio C Hamano
Message 16 of 17 in “bound upload-pack memory allocations”
  1. 0/9 bound upload-pack memory allocationsJeff King, Feb 28, 2024
  2. 1/9 upload-pack: drop separate v2 "haves" arrayJeff King, Feb 28, 2024
  3. 2/9 upload-pack: switch deepen-not list to an oid_arrayJeff King, Feb 28, 2024
  4. 3/9 upload-pack: use oidset for deepen_not listJeff King, Feb 28, 2024
  5. 4/9 upload-pack: use a strmap for want-ref linesJeff King, Feb 28, 2024
  6. 5/9 upload-pack: accept only a single packfile-uri lineJeff King, Feb 28, 2024
  7. 6/9 upload-pack: disallow object-info capability by defaultJeff King, Feb 28, 2024
  8. Patrick SteinhardtMar 4, 2024
  9. Jeff KingMar 4, 2024
  10. Taylor BlauApr 29, 2024
  11. 7/9 upload-pack: always turn off save_commit_bufferJeff King, Feb 28, 2024
  12. 8/9 upload-pack: use PARSE_OBJECT_SKIP_HASH_CHECK in more placesJeff King, Feb 28, 2024
  13. 9/9 upload-pack: free tree buffers after parsingJeff King, Feb 28, 2024
  14. Patrick SteinhardtMar 4, 2024
  15. Jeff KingMar 4, 2024
  16. Patrick SteinhardtMar 4, 2024
  17. Junio C HamanoFeb 28, 2024

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.