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

Re: [PATCH 1/2] fetch: add top-level trace2 regions

From
Josh Steadmon <steadmon@google.com>
Date
Aug 19, 2024, 18:26 UTC
Message-ID
<erfaq73yp2w2kblymuuohxuj535j5dixdildwhnomv7sfcd2z2@gbtrvnztgkgj>
In-Reply-To
<xmqqh6blsh43.fsf@gitster.g>
On 2024.08.15 12:47, Junio C Hamano wrote:
Show 22 quoted lines
> Josh Steadmon <steadmon@google.com> writes:
> 
> > -	if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri) &&
> > -	    fetch_bundle_uri(the_repository, bundle_uri, NULL))
> > -		warning(_("failed to fetch bundles from '%s'"), bundle_uri);
> > +	if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri)) {
> > +		int result = 0;
> 
> This needs no initialization.
> 
> > +		trace2_region_enter("fetch", "fetch-bundle-uri", the_repository);
> > +		result = fetch_bundle_uri(the_repository, bundle_uri, NULL);
> > +		trace2_region_leave("fetch", "fetch-bundle-uri", the_repository);
> > +		if (result)
> > +			warning(_("failed to fetch bundles from '%s'"), bundle_uri);
> > +	}
> 
> It is a bit sad that the concise original with straight-forward
> control flow had to be butchered like this to sprinkle tracing code
> in it, but I guess that cannot be helped?  I wonder if it becomes
> much less invasive and more future proof to define the trace region
> in the fetch_bundle_uri() function itself.  Has it been considered?
Moved to fetch_bundle_uri() in v2.
Show 29 quoted lines
> > @@ -2407,6 +2412,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
> >  		struct oidset_iter iter;
> >  		const struct object_id *oid;
> >  
> > +		trace2_region_enter("fetch", "negotiate-only", the_repository);
> >  		if (!remote)
> >  			die(_("must supply remote when using --negotiate-only"));
> >  		gtransport = prepare_transport(remote, 1);
> > @@ -2415,6 +2421,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
> >  		} else {
> >  			warning(_("protocol does not support --negotiate-only, exiting"));
> >  			result = 1;
> > +			trace2_region_leave("fetch", "negotiate-only", the_repository);
> >  			goto cleanup;
> >  		}
> >  		if (server_options.nr)
> > @@ -2425,11 +2432,17 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
> >  		while ((oid = oidset_iter_next(&iter)))
> >  			printf("%s\n", oid_to_hex(oid));
> >  		oidset_clear(&acked_commits);
> > +		trace2_region_leave("fetch", "negotiate-only", the_repository);
> 
> OK.  Both error path and normal path we leave the region we entered.
> 
> A complete tangent, but do we have an automated test or code
> analysis that catches us if we forget to leave an entered region
> (i.e., imagine we didn't leave in the else clause after issuing the
> warning---we remain in the region in such an error case, even though
> normally we leave the region correctly)?

It's been discussed before [1], but the general feeling seems to be that it's not worth the effort / test runtime.

[1] https://lore.kernel.org/git/xmqqbka27zu9.fsf@gitster.g/
Previous: Junio C HamanoNext: Josh Steadmon
Message 4 of 13 in “Add additional trace2 regions for fetch and push”
  1. 0/2 Add additional trace2 regions for fetch and pushJosh Steadmon, Aug 15, 2024
  2. 1/2 fetch: add top-level trace2 regionsJosh Steadmon, Aug 15, 2024
  3. Junio C HamanoAug 15, 2024
  4. Josh SteadmonAug 19, 2024
  5. 2/2 send-pack: add new tracing regions for pushJosh Steadmon, Aug 15, 2024
  6. Junio C HamanoAug 15, 2024
  7. Josh SteadmonAug 22, 2024
  8. Junio C HamanoAug 22, 2024
  9. 0/3 Add additional trace2 regions for fetch and pushJosh Steadmon, Aug 22, 2024
  10. 1/3 trace2: implement trace2_printf() for event targetJosh Steadmon, Aug 22, 2024
  11. 2/3 fetch: add top-level trace2 regionsJosh Steadmon, Aug 22, 2024
  12. 3/3 send-pack: add new tracing regions for pushJosh Steadmon, Aug 22, 2024
  13. Junio C HamanoAug 22, 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.