From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.155 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796318221; b=LA+DP5rqjtNyXdcoZPq0ySobDLPFGI0nUPhvx1ZGQXRNf1pxOGHCYCGK9Y1mXv6sKT1J FH2muxHEp6EKC4EaPymO+wxV4/kpggUbg75OL02Jm9xFkWdKrD3R/etkXvDcBp+FbWXe/ oii/1Uiorn9yzJsPS3QaSne0pyJduBNsPke5FXg+8I3Oy99X4CDwWN1EQU7HpguXuVwDF Y1kmdum4OOvwutGItVBG4M+OwiIOoD+9YpxwBjicjQdR/eLOtQUeZX1dQrFgwpr3d3cFS iUnNxFVJkGwCvULUpiD65t0yUDfvl9CLjH4h8mOCF1HKpwEjxyV5ICzXYd1cgQKu8vA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796318221; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=ug6HhbXMdfUjuhQXYKq7sKwsfx+YIxJKn/9ffSF6vmg=; b=qVYeoMt+VMKcakk9pOFWlcIBtj9LIEof/zLzZMpIinbLZ5lKGX9AmqAN4/L5s7DgZWLm 5R2mQlUygR+5io9Jk6gxu9UED0eMEWlE9q+09kIye/2k/QSkByLuUl/EWjJtVaT52R5oz 1VhKO1gl3+OuHZ6zgbctSEeoVR7mex61/76o+x6tQmZeGugIXMHUqUhZmoI3LWK5+2QI4 oXagmoXkPekgHfPdmSBnjhB5YcXpgkPDL/a6TQ8aN+2Oiay1emum7tbeqofO/bXKYK1pu TFg4XRsacc8CoFSMnFaqP+dgFpNddxD0mjCXKT24+b2lOkXyklcayGAZVIp3CaErMaQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=MlF66YSj; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=lVx8HNXK; arc=none smtp.remote-ip=103.168.172.155 Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00CB0606A322 for ; Thu, 3 Dec 2026 17:17:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 00CB0606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=MlF66YSj; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=lVx8HNXK Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0B51014000AD for ; Thu, 3 Dec 2026 12:17:00 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 03 Dec 2026 12:17:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796318220; x=1796404620; bh=ug6HhbXMdf UjuhQXYKq7sKwsfx+YIxJKn/9ffSF6vmg=; b=MlF66YSjVR1yZqb0igEjZ3oIQ3 6f8Gypvw4EdcMGj5OzDj124b4OZhCOtAlHrw06kmruYseAOvSbEdz80HBw08tUtz TkKq4/naDTmf6j0vAAicY33JmH9/fssQQdwO8eKa6M6qJhcyR87wI6ahd3jFAL1U COWuHBHojtFaMlGM/S/nBbreNPjn6FB3Lu2xz7i9dajdMFmuIty1TLn557JdE65B hTTzvxnxQHYfSuodEolBNB6a28eTmNLU16rKp9AP24AZguYt2h9i9iD+olmJsMHt giH8/I5FrPWgJmf3SRw5oO6lr2OxLCpjznyWauhCOsWJMHeJsEy2aMCc53iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796318220; x=1796404620; bh=ug6HhbXMdfUjuhQXYKq7sKwsfx+YIxJKn/9 ffSF6vmg=; b=lVx8HNXKWDsbv/w/vvltfXJVYwhWJk9XKo2weuhJTJWKjbq35sT MjFQyrunOTzXN5VuBE4orksidn7HF2eD/zPnbsc7sPqjI59RGaRxsWc3F96/GPxN pHrFqsOI93qeahaivv3kyaNcIJHh1PKzSL8cU8AXh528eKGmDlzgr+fgN1R2HW3C ej+m3L4GXsLBmOEk4dMW/nu8ka42GYaMYPxXOieMyYvJ0VfbxE8WzFvnsB9vjQLv fXx8kS4yf+nbt570AymvoUzgO8HvAilgrBMxph6TX66dYBgfW6V/9iYp3tt7Fols /3r0AxGCb0lKnmrnmCUcHG3Mjqj/QIV2lcg== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796318220; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:ptaVfhmwTIwH4Lb/dDh5iMCEzo3qBGTr8Jw9MoBXFDn6xRR FiHC2AwT6dz6EmvioV2lkzNKnyODfN7Ns00WMaJIk0Qnb9Ag+Xaf6xoVFliKNPVp EXqLtVpItjSxJImU2Sg/vylmfp1onOlx8AYDYOAKo6jxcmdRKo3Nm6wKfwNbuTRU vyn8sfn8yYA/cGYNVRGp5vHeenC6NYO4nEn0TgA+nqWPUNFehTGPO2ss0FTZprKG 8bht7Mg7YvXZzuSP+lvGiSL5xtOFIA4x6h4bdrbp95+HfY8xH5gFeRpnenhTIdf4 isnJ/4BzXvuq7C5D5Jq3jpAmt5SNNM782lkRm+A==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:qkIuyJOkY19rP/PYTPDzQqhrtnTzENuAFOXGcJ4hZlM=:/88b1nOeTeTHS9z1ZO1rAJvod0e4S8GENDCJLtq6N74=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFbNKzO7kIF6Sv6AXQVr9ZCTR76+XvAWvq9SaAAOQhRc2n8uNmGJhPEMfBbVw5Tnf q99D7bCKrUJ1grG1Si3HME4lILUX8waROVC43n2k+VszwnPhzEiavZkEoYh7YDs3r89+0m xGK6m4P/0oJGZHVbduYvznF2kxtMu3j571gKUKgyPTcizRdeLa694DJl/pLniwOdQW/K9P H2aBRPBW/33N6bkk2XCY8qj+I1hwjXcxdpjtZkv6H6DGCcMj2uXLwvQTAK5sQXdEDD1pzR 1zL2/9UcwcgeyDHZYA5eTuYfUtYusdl426LEERFk8tYiWZK13s3vFHBpw1c8eD5bD5vspW vd+tytFvXBUVzFtpJnHOEXO79SfltNJSEW51XebK/XHVBGs16ynN8I3Bo3wSg1F6v90x8A pq9MmF/VF8uAzabmlp8Gh55Xi47O+QAlo1tkAa0X35X5w67zPOJyb5KL+vWsb0XwbAdNAB LEYS33zV20u3wrtAe1Ek14N+P9t3MLDfQQit9Dl4i1s6JLtzNQw7cZ6xJdaayO2Bd2YsEG KHOUlCiiIjBglUuhVTuD5eoNsQRifiSwym0VgKB3hoOHHDroRWM+Hm9J73JjOQFWId/L9t FBQYVfUCzZdsy1DVIbzUOgdA1gMZIWccl6BV4xaYE4SNj8UsLGJ6SfReiT/Q X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Dec 2026 12:16:59 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id 2e337100 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 3 Dec 2026 17:16:57 +0000 (UTC) Date: Thu, 3 Dec 2026 18:16:54 +0100 From: Patrick Steinhardt To: Kaartic Sivaraam Cc: Junio C Hamano , git@vger.kernel.org Subject: Re: [PATCH v2 5/7] commit-graph: decide mergeable and chainable layers by depth Message-ID: References: <20261120-pks-odb-pluggable-commit-graphs-v2-0-31f2341a9932@pks.im> <20261120-pks-odb-pluggable-commit-graphs-v2-5-31f2341a9932@pks.im> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Dec 03, 2026 at 07:08:20PM +0530, Kaartic Sivaraam wrote: > On 11/20/26 17:52, Patrick Steinhardt wrote: > > When writing a split commit graph, `split_graph_merge_strategy()` > > decides which layers of the existing chain get merged into the new > > layer and which layer the new one builds upon. This is decided on two > > simple rules: > > > > - A layer may be merged in case it is part of the same local object > > directory. > > > > - A layer may be added to the chain in case it is either a split > > commit graph layer, regardless of whether it is local or not. Or in > > case it is local, we may also add it to our chain in case it is a > > non-split commit graph, in which case we convert it to a split one. > > > > I found this hard to interpret too as Justin mentions elsewhere. Could we > rephrase it as follows? > > - A layer may be merged into the new layer only if it is local, > that is, it lives in the object directory we are writing to. > > - A layer may be kept as a base of the new layer if it is a split > commit-graph layer, whether it is local or comes from an > alternate. A non-split commit-graph may also be kept, but only if > it is local, because we have to convert it into a split layer > first. Yeah, that reads better indeed. > > diff --git a/commit-graph.c b/commit-graph.c > > index e48d8fc0a78..ff2a5cbcbac 100644 > > --- a/commit-graph.c > > +++ b/commit-graph.c > > @@ -1157,6 +1157,8 @@ struct write_commit_graph_context { > > uint64_t progress_cnt; > > char *base_graph_name; > > + size_t mergeable_layers; > > + size_t chainable_layers; > > These are counts from the top of the existing chain, which isn't > obvious from the names alone. A short comment would help, for example: > > /* > * Number of topmost layers of the existing chain that may be > * merged into the new layer, and that the new layer may be > * built on top of, respectively. > */ I guess I was getting lazy because all the other fields in this structure are undocumented, as well. That's not a good enough reason though. > > + /* > > + * We only consider merging layers that belong to our own object > > + * directory. Furthermore, we can only chain on top of either: > > + * > > + * - A split commit graph layer, regardless of whether or not it is > > + * local. > > + * > > + * - A local non-split commit graph, in which case we'll convert that > > + * layer into a split commit graph layer. > > + */ > > + for (struct commit_graph *layer = g; layer; layer = layer->base_graph) { > > We call split_graph_merge_strategy only when COMMIT_GRAPH_WRITE_SPLIT is > set. So, shall we wrap this for loop such that it runs only when that flag > is set? Hmm, yes, that's true. I guess we can, and in tha tcase we can merge it with a loop that we have a bit further down. > > + char *path = get_commit_graph_filename(layer->dir); > > + bool is_split = !!strcmp(layer->filename, path); > > + bool is_local = !strcmp(layer->dir, ctx.dir); > > + > > + free(path); > > + > > + if (!is_local && !is_split) > > + break; > > + if (!is_local) > > + mergeable = false; > > It took me a moment to see why `mergeable` latches to false instead > of being recomputed for each layer. I think it's because we can only > ever merge the topmost layers: the new layer replaces the layers it > merges and sits on top of the rest, so once one layer can't be merged, > nothing below it can be either. The old loop got this by breaking out > at the first non-local layer. > > Could the comment say so? Something like: > > /* > * We can only merge a run of layers from the top of the chain, > * so merging stops at the first layer that is not in our own > * object directory. [...] > */ But the comment above already says that, doesn't it? * We only consider merging layers that belong to our own object * directory. Patrick