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

Re: [PATCH v3 2/5] fetch-pack: load tip_oids eagerly iff needed

From
Jeff King <peff@peff.net>
Date
Oct 4, 2018, 22:07 UTC
Message-ID
<20181004220711.GA28287@sigill.intra.peff.net>
In-Reply-To
<9f51ac28-73e9-2855-c650-7d695945e286@web.de>
On Thu, Oct 04, 2018 at 05:09:39PM +0200, René Scharfe wrote:
Show 7 quoted lines
> tip_oids_contain() lazily loads refs into an oidset at its first call.
> It abuses the internal (sub)member .map.tablesize of that oidset to
> check if it has done that already.
> 
> Determine if the oidset needs to be populated upfront and then do that
> instead.  This duplicates a loop, but simplifies the existing one by
> separating concerns between the two.
I like this approach much better than what I showed earlier. But...
Show 18 quoted lines
> diff --git a/fetch-pack.c b/fetch-pack.c
> index 3b317952f0..53914563b5 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -526,23 +526,6 @@ static void add_refs_to_oidset(struct oidset *oids, struct ref *refs)
>  		oidset_insert(oids, &refs->old_oid);
>  }
>  
> -static int tip_oids_contain(struct oidset *tip_oids,
> -			    struct ref *unmatched, struct ref *newlist,
> -			    const struct object_id *id)
> -{
> -	/*
> -	 * Note that this only looks at the ref lists the first time it's
> -	 * called. This works out in filter_refs() because even though it may
> -	 * add to "newlist" between calls, the additions will always be for
> -	 * oids that are already in the set.
> -	 */

I don't think the subtle point this comment is making goes away. We're still growing the list in the loop that calls tip_oids_contain() (and which now calls just oidset_contains). That's OK for the reasons given here, but I think that would need to be moved down to this code:

Show 11 quoted lines
> +	if (strict) {
> +		for (i = 0; i < nr_sought; i++) {
> +			ref = sought[i];
> +			if (!is_unmatched_ref(ref))
> +				continue;
> +
> +			add_refs_to_oidset(&tip_oids, unmatched);
> +			add_refs_to_oidset(&tip_oids, newlist);
> +			break;
> +		}
> +	}

I.e., we need to say here why it's OK to summarize newlist in the oidset, even though we're adding to it later.

-Peff
Previous: Jeff KingNext: René Scharfe
Message 18 of 26 in “oidset: use khash”
  1. 0/2 oidset: use khashRené Scharfe, Oct 3, 2018
  2. 1/2 khash: factor out kh_release_*René Scharfe, Oct 3, 2018
  3. 2/2 oidset: use khashRené Scharfe, Oct 3, 2018
  4. Jeff KingOct 3, 2018
  5. René ScharfeOct 4, 2018
  6. Jeff KingOct 4, 2018
  7. Jeff KingOct 4, 2018
  8. René ScharfeOct 4, 2018
  9. 0/5 oidset: use khashRené Scharfe, Oct 4, 2018
  10. 1/5 fetch-pack: factor out is_unmatched_ref()René Scharfe, Oct 4, 2018
  11. 2/5 fetch-pack: load tip_oids eagerly iff neededRené Scharfe, Oct 4, 2018
  12. Jonathan TanOct 4, 2018
  13. René ScharfeOct 4, 2018
  14. René ScharfeOct 5, 2018
  15. Jeff KingOct 4, 2018
  16. Jonathan TanOct 4, 2018
  17. Jeff KingOct 4, 2018
  18. Jeff KingOct 4, 2018
  19. René ScharfeOct 5, 2018
  20. Jeff KingOct 5, 2018
  21. René ScharfeOct 5, 2018
  22. Jeff KingOct 5, 2018
  23. 3/5 khash: factor out kh_release_*René Scharfe, Oct 4, 2018
  24. 4/5 oidset: use khashRené Scharfe, Oct 4, 2018
  25. 5/5 oidset: uninline oidset_init()René Scharfe, Oct 4, 2018
  26. Jeff KingOct 4, 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.