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

Re: [PATCH 2/2] cache-tree: prefetch in partial clone read-tree

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 23, 2021, 21:20 UTC
Message-ID
<xmqqsg04loas.fsf@gitster.g>
In-Reply-To
<f4881b7455b9d33c8a53a91eda7fbdfc5d11382c.1627066238.git.jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 7 quoted lines
> @@ -466,6 +470,9 @@ int cache_tree_update(struct index_state *istate, int flags)
>  	if (!istate->cache_tree)
>  		istate->cache_tree = cache_tree();
>  
> +	if (!(flags & WRITE_TREE_MISSING_OK) && has_promisor_remote())
> +		prefetch_cache_entries(istate, must_check_existence);
> +
It's so nice when a "fix" to an issue can be this simple.
Thanks; will queue.
Show 42 quoted lines
>  	trace_performance_enter();
>  	trace2_region_enter("cache_tree", "update", the_repository);
>  	i = update_one(istate->cache_tree, istate->cache, istate->cache_nr,
> diff --git a/t/t1022-read-tree-partial-clone.sh b/t/t1022-read-tree-partial-clone.sh
> new file mode 100755
> index 0000000000..a763e27c7d
> --- /dev/null
> +++ b/t/t1022-read-tree-partial-clone.sh
> @@ -0,0 +1,33 @@
> +#!/bin/sh
> +
> +test_description='git read-tree in partial clones'
> +
> +TEST_NO_CREATE_REPO=1
> +
> +GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
> +export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'read-tree in partial clone prefetches in one batch' '
> +	test_when_finished "rm -rf server client trace" &&
> +
> +	git init server &&
> +	echo foo >server/one &&
> +	echo bar >server/two &&
> +	git -C server add one two &&
> +	git -C server commit -m "initial commit" &&
> +	TREE=$(git -C server rev-parse HEAD^{tree}) &&
> +
> +	git -C server config uploadpack.allowfilter 1 &&
> +	git -C server config uploadpack.allowanysha1inwant 1 &&
> +	git clone --bare --filter=blob:none "file://$(pwd)/server" client &&
> +	GIT_TRACE_PACKET="$(pwd)/trace" git -C client read-tree $TREE &&
> +
> +	# "done" marks the end of negotiation (once per fetch). Expect that
> +	# only one fetch occurs.
> +	grep "fetch> done" trace >donelines &&
> +	test_line_count = 1 donelines
> +'
> +
> +test_done
Previous: Jonathan TanNext: Elijah Newren
Message 6 of 8 in “Another partial clone prefetch”
  1. 0/2 Another partial clone prefetchJonathan Tan, Jul 23, 2021
  2. 1/2 unpack-trees: refactor prefetching codeJonathan Tan, Jul 23, 2021
  3. Elijah NewrenJul 23, 2021
  4. 2/2 cache-tree: prefetch in partial clone read-treeJonathan Tan, Jul 23, 2021
  5. Jonathan TanJul 23, 2021
  6. Junio C HamanoJul 23, 2021
  7. Elijah NewrenJul 23, 2021
  8. Derrick StoleeJul 26, 2021

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.