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

[PATCH 1/4] peel_ref: use faster deref_tag_noverify

From
Jeff King <peff@peff.net>
Date
Oct 4, 2012, 07:58 UTC
Message-ID
<20121004075815.GA31325@sigill.intra.peff.net>
In-Reply-To
<20121004075609.GA1355@sigill.intra.peff.net>

When we are asked to peel a ref to a sha1, we internally call deref_tag, which will recursively parse each tagged object until we reach a non-tag. This has the benefit that we will verify our ability to load and parse the pointed-to object.

However, there is a performance downside: we may not need to load that object at all (e.g., if we are listing peeled simply listing peeled refs), or it may be a large object that should follow a streaming code path (e.g., an annotated tag of a large blob).

It makes more sense for peel_ref to choose the fast thing rather than performing the extra check, for two reasons:

  1. We will already sometimes short-circuit the tag parsing
     in favor of a peeled entry from a packed-refs file. So
     we are already favoring speed in some cases, and it is
     not wise for a caller to rely on peel_ref to detect
     corruption.
  2. We already silently ignore much larger corruptions,
     like a ref that points to a non-existent object, or a
     tag object that exists but is corrupted.
  2. peel_ref is not the right place to check for such a
     database corruption. It is returning only the sha1
     anyway, not the actual object. Any callers which use
     that sha1 to load an object will soon discover the
     corruption anyway, so we are really just pushing back
     the discovery to later in the program.
Signed-off-by: Jeff King <peff@peff.net>
---
This is basically bringing the optimization from 90108a2 (upload-pack:
avoid parsing tag destinations, 2012-01-06) to users of peel_ref.
 refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/refs.c b/refs.c
index da74a2b..0a916a0 100644
--- a/refs.c
+++ b/refs.c
@@ -1225,7 +1225,7 @@ fallback:
 fallback:
 	o = parse_object(base);
 	if (o && o->type == OBJ_TAG) {
-		o = deref_tag(o, refname, 0);
+		o = deref_tag_noverify(o);
 		if (o) {
 			hashcpy(sha1, o->sha1);
 			return 0;
-- 
1.8.0.rc0.10.g8dd2a92
Previous: Jeff KingNext: Junio C Hamano
Message 2 of 14 in “optimizing upload-pack ref peeling”
  1. 0/4 optimizing upload-pack ref peelingJeff King, Oct 4, 2012
  2. 1/4 peel_ref: use faster deref_tag_noverifyJeff King, Oct 4, 2012
  3. Junio C HamanoOct 4, 2012
  4. 2/4 peel_ref: do not return a null sha1Jeff King, Oct 4, 2012
  5. Junio C HamanoOct 4, 2012
  6. 3/4 peel_ref: check object type before loadingJeff King, Oct 4, 2012
  7. Junio C HamanoOct 4, 2012
  8. Jeff KingOct 4, 2012
  9. Junio C HamanoOct 4, 2012
  10. Jeff KingOct 4, 2012
  11. 4/4 upload-pack: use peel_ref for ref advertisementsJeff King, Oct 4, 2012
  12. Jeff KingOct 4, 2012
  13. Ævar Arnfjörð BjarmasonOct 4, 2012
  14. Nazri RamliyOct 4, 2012

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.