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

Re: [PATCH v2 6/7] fetch: merge fetching and consuming refs

From
Derrick Stolee <stolee@gmail.com>
Date
Aug 25, 2021, 14:26 UTC
Message-ID
<439cb382-a4d0-18ad-5475-0cb29fba98e7@gmail.com>
In-Reply-To
<31d9f72edf5c178b2e80c30bb7c0a9bc164ca5eb.1629800774.git.ps@pks.im>
On 8/24/2021 6:37 AM, Patrick Steinhardt wrote:
Show 6 quoted lines
> -		if (ret) {
> -			transport_unlock_pack(transport);
> -			return ret;
> -		}
> +		if (ret)
> +			goto out;

You were just reorganizing this method in the previous patch. This "goto out" trick could have applied there instead, which wouldn't complicate that patch and would simplify this one.

But perhaps it would look strange to have the following ending to the method, even if for only one patch:

	return 0;
out:
	transport_unlock_pack(transport);
	return res;
}
So, feel free to ignore me here. Decide based on your taste.
Show 24 quoted lines
>  	}
>  
> -	/*
> -	 * Keep the new pack's ".keep" file around to allow the caller
> -	 * time to update refs to reference the new objects.
> -	 */
> -	return 0;
> -}
> -
> -/* Update local refs based on the ref values fetched from a remote */
> -static int consume_refs(struct transport *transport, struct ref *ref_map)
> -{
> -	int connectivity_checked = transport->smart_options
> +	connectivity_checked = transport->smart_options
>  		? transport->smart_options->connectivity_checked : 0;
> -	int ret;
> +
>  	trace2_region_enter("fetch", "consume_refs", the_repository);
>  	ret = store_updated_refs(transport->url,
>  				 transport->remote->name,
>  				 connectivity_checked,
>  				 ref_map);
> -	transport_unlock_pack(transport);
>  	trace2_region_leave("fetch", "consume_refs", the_repository);

This transport_unlock_pack() is leaving the trace2 region. I think it is unlikely that the loop of unlink_or_warn() calls will take significant time that affects this region, so it should be fine to move it.

Show 5 quoted lines
> +
> +out:
> +	transport_unlock_pack(transport);
>  	return ret;
>  }
...
Show 12 quoted lines
> -	if (!fetch_refs(transport, ref_map))
> -		consume_refs(transport, ref_map);
> +	fetch_and_consume_refs(transport, ref_map);
>  
>  	if (gsecondary) {
>  		transport_disconnect(gsecondary);
> @@ -1610,7 +1600,7 @@ static int do_fetch(struct transport *transport,
>  				   transport->url);
>  		}
>  	}
> -	if (fetch_refs(transport, ref_map) || consume_refs(transport, ref_map)) {
> +	if (fetch_and_consume_refs(transport, ref_map)) {
The end goal of making these consumers simpler is worth it.

Thanks, -Stolee

Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 34 of 48 in “Speed up mirror-fetches with many refs”
  1. 0/6 Speed up mirror-fetches with many refsPatrick Steinhardt, Aug 20, 2021
  2. 1/6 fetch: speed up lookup of want refs via commit-graphPatrick Steinhardt, Aug 20, 2021
  3. Derrick StoleeAug 20, 2021
  4. Junio C HamanoAug 20, 2021
  5. Patrick SteinhardtAug 23, 2021
  6. Derrick StoleeAug 25, 2021
  7. 2/6 fetch: avoid unpacking headers in object existence checkPatrick Steinhardt, Aug 20, 2021
  8. Ævar Arnfjörð BjarmasonAug 25, 2021
  9. 3/6 connected: refactor iterator to return next object ID directlyPatrick Steinhardt, Aug 20, 2021
  10. Derrick StoleeAug 20, 2021
  11. Junio C HamanoAug 20, 2021
  12. René ScharfeAug 20, 2021
  13. Patrick SteinhardtAug 23, 2021
  14. 4/6 fetch-pack: optimize loading of refs via commit graphPatrick Steinhardt, Aug 20, 2021
  15. Derrick StoleeAug 20, 2021
  16. 5/6 fetch: refactor fetch refs to be more extendablePatrick Steinhardt, Aug 20, 2021
  17. Derrick StoleeAug 20, 2021
  18. 6/6 fetch: avoid second connectivity check if we already have all objectsPatrick Steinhardt, Aug 20, 2021
  19. Derrick StoleeAug 20, 2021
  20. Patrick SteinhardtAug 23, 2021
  21. Derrick StoleeAug 20, 2021
  22. Junio C HamanoAug 21, 2021
  23. 0/7 Speed up mirror-fetches with many refsPatrick Steinhardt, Aug 24, 2021
  24. 1/7 fetch: speed up lookup of want refs via commit-graphPatrick Steinhardt, Aug 24, 2021
  25. Derrick StoleeAug 25, 2021
  26. 2/7 fetch: avoid unpacking headers in object existence checkPatrick Steinhardt, Aug 24, 2021
  27. 3/7 connected: refactor iterator to return next object ID directlyPatrick Steinhardt, Aug 24, 2021
  28. 4/7 fetch-pack: optimize loading of refs via commit graphPatrick Steinhardt, Aug 24, 2021
  29. 5/7 fetch: refactor fetch refs to be more extendablePatrick Steinhardt, Aug 24, 2021
  30. Derrick StoleeAug 25, 2021
  31. Patrick SteinhardtSep 1, 2021
  32. 7/7 fetch: avoid second connectivity check if we already have all objectsPatrick Steinhardt, Aug 24, 2021
  33. 6/7 fetch: merge fetching and consuming refsPatrick Steinhardt, Aug 24, 2021
  34. Derrick StoleeAug 25, 2021
  35. Patrick SteinhardtSep 1, 2021
  36. Junio C HamanoAug 24, 2021
  37. Patrick SteinhardtAug 25, 2021
  38. Derrick StoleeAug 25, 2021
  39. 0/7 Speed up mirror-fetches with many refsPatrick Steinhardt, Sep 1, 2021
  40. 1/7 fetch: speed up lookup of want refs via commit-graphPatrick Steinhardt, Sep 1, 2021
  41. 2/7 fetch: avoid unpacking headers in object existence checkPatrick Steinhardt, Sep 1, 2021
  42. 3/7 connected: refactor iterator to return next object ID directlyPatrick Steinhardt, Sep 1, 2021
  43. 4/7 fetch-pack: optimize loading of refs via commit graphPatrick Steinhardt, Sep 1, 2021
  44. 5/7 fetch: refactor fetch refs to be more extendablePatrick Steinhardt, Sep 1, 2021
  45. 6/7 fetch: merge fetching and consuming refsPatrick Steinhardt, Sep 1, 2021
  46. 7/7 fetch: avoid second connectivity check if we already have all objectsPatrick Steinhardt, Sep 1, 2021
  47. Junio C HamanoSep 1, 2021
  48. Junio C HamanoSep 8, 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.