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

Re: [PATCH v2 1/2] sha1-file: support OBJECT_INFO_FOR_PREFETCH

From
Jeff King <peff@peff.net>
Date
Apr 5, 2019, 22:00 UTC
Message-ID
<20190405220005.GA10312@sigill.intra.peff.net>
In-Reply-To
<068861632b85179d2a5a5ceb966e951a78b27141.1553895166.git.jonathantanmy@google.com>
On Fri, Mar 29, 2019 at 02:39:27PM -0700, Jonathan Tan wrote:
Show 10 quoted lines
> Teach oid_object_info_extended() to support a new flag that inhibits
> fetching of missing objects. This is equivalent to setting
> fetch_is_missing to 0, calling oid_object_info_extended(), then setting
> fetch_if_missing to whatever it was before. Update unpack-trees.c to use
> this new flag instead of repeatedly setting fetch_if_missing.
> 
> This new flag complicates things slightly in that there are now 2 ways
> to do the same thing. But this eliminates the need to repeatedly set a
> global variable, and more importantly, allows prefetching to be done in
> parallel (in the future); hence, this patch.

Sorry I'm a little late to review this. I don't have any critical comments, so if this gets ignored, I'll live with it.

Show 6 quoted lines
> +/*
> + * Do not attempt to fetch the object if missing (even if fetch_is_missing is
> + * nonzero). This is meant for bulk prefetching of missing blobs in a partial
> + * clone. Implies OBJECT_INFO_QUICK.
> + */
> +#define OBJECT_INFO_FOR_PREFETCH (32 + OBJECT_INFO_QUICK)

Mostly I found the name and semantics of this flag to be a little confusing. Really what we want is to tell oid_object_info() not do any on-demand fetching for us. That seems like a thing that we might eventually want for other purposes (e.g., a diff operation that could produce a real blob diff but would be happy outputting a less-detailed tree diff).

If it were just OBJECT_INFO_NO_FETCH or similar, that tells more clearly what it does, and would make sense in more contexts.

I suspect that QUICK would be the norm when used with it, though I probably would have kept the two orthogonal for the sake of simplicity and clarity.

Show 26 quoted lines
> diff --git a/unpack-trees.c b/unpack-trees.c
> index 22c41a3ba8..381b0cd65e 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -404,20 +404,21 @@ static int check_updates(struct unpack_trees_options *o)
>  		 * below.
>  		 */
>  		struct oid_array to_fetch = OID_ARRAY_INIT;
> -		int fetch_if_missing_store = fetch_if_missing;
> -		fetch_if_missing = 0;
>  		for (i = 0; i < index->cache_nr; i++) {
>  			struct cache_entry *ce = index->cache[i];
> -			if ((ce->ce_flags & CE_UPDATE) &&
> -			    !S_ISGITLINK(ce->ce_mode)) {
> -				if (!has_object_file(&ce->oid))
> -					oid_array_append(&to_fetch, &ce->oid);
> -			}
> +
> +			if (!(ce->ce_flags & CE_UPDATE) ||
> +			    S_ISGITLINK(ce->ce_mode))
> +				continue;
> +			if (!oid_object_info_extended(the_repository, &ce->oid,
> +						      NULL,
> +						      OBJECT_INFO_FOR_PREFETCH))
> +				continue;
> +			oid_array_append(&to_fetch, &ce->oid);

Here we get rid of the global set/restore dance, which is nice. But there's also a behavior change, as we've picked up QUICK. I think that's probably the right thing to do, but I was a bit surprised not to see any discussion in the commit message.

-Peff
Previous: Johannes SchindelinNext: Jonathan Tan
Message 8 of 29 in “diff: batch fetching of missing blobs”
  1. diff: batch fetching of missing blobsJonathan Tan, Mar 26, 2019
  2. SZEDER GáborMar 27, 2019
  3. Johannes SchindelinMar 27, 2019
  4. Jeff KingMar 28, 2019
  5. 0/2 Batch fetching of missing blobs in diff and showJonathan Tan, Mar 29, 2019
  6. 1/2 sha1-file: support OBJECT_INFO_FOR_PREFETCHJonathan Tan, Mar 29, 2019
  7. Johannes SchindelinApr 5, 2019
  8. Jeff KingApr 5, 2019
  9. 2/2 diff: batch fetching of missing blobsJonathan Tan, Mar 29, 2019
  10. SZEDER GáborApr 4, 2019
  11. Johannes SchindelinApr 5, 2019
  12. Christian CouderApr 7, 2019
  13. Junio C HamanoApr 8, 2019
  14. Junio C HamanoApr 8, 2019
  15. Junio C HamanoApr 8, 2019
  16. Christian CouderApr 8, 2019
  17. Christian CouderApr 8, 2019
  18. Junio C HamanoApr 8, 2019
  19. Christian CouderApr 8, 2019
  20. Duy NguyenApr 5, 2019
  21. fixup! diff: batch fetching of missing blobsJonathan Tan, Apr 5, 2019
  22. Johannes SchindelinApr 5, 2019
  23. Duy NguyenApr 6, 2019
  24. Junio C HamanoApr 8, 2019
  25. Junio C HamanoApr 8, 2019
  26. Duy NguyenApr 8, 2019
  27. Junio C HamanoApr 9, 2019
  28. Johannes SchindelinApr 5, 2019
  29. Jeff KingApr 5, 2019

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.