From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796305105; b=vcjSBNHqRgd69X9fIUHOnOQdOFSIUGZXqTIZTbYUO9YWIDzzkFZwDNBqLiUl1IWaFzV1 Hx5ZrMqz8cv6uXpY2K8wBprX8kwS4AXwM/Mk/AEntgQZXzrZko9cfUMXhZGZm/glQC7Rx mx5BS6idOoFIXQw/K7whW6MYjUTvIYPlmJV9p6HyalhyPmYRJDpUdOILwu5DOkVjsRvyF fZMWEEV5XL0RMmt72pV0cLpn5YCffZZ0XgDTmG/+se1aeSs9xVc2Wv1oodSr5TZemSmB5 qOzT/rWgUxAyOb8HjTw8XNORTvqF1vebSrkyh+U86GC1vOXlv7nXNx3GdHbUMuMDVRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796305105; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=H8GKBuXvIFJH/OgoS1akZt0kffQzR9y9nIKZM/ekhhI=; b=JkdZknHhVtTnWT6vPlQXQELmoQplYqqwluU8NQOlLGi/tWwlHXJ/Bv7gVwoS2g7fcuQN RuPYjsuyZShtwNvAIZGdKVQjYWWlumb9Jm1JTxzwT+1Oed81GSpu2Kb+zj5p5koSDc5pk 8MbjdIBbq1a2dYDAw+xkyB7s6KtDGfKgylsxWJuTosm6J4IxWqgM2pAnuDQ5x7iLzrRud LDkfm7rL+rP6OtQIRLubKKLylkAeDooifWImyQSGWK72+DqjvTa5QKUn9xBhQc6LI0rn1 n8+JzwdASY9jNCHzhUBTgb6+dxwV9dsZoBoYyvvtOuR1QpeUqgr51WyJVoy1e2XjuTg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Dh7UlAkO; arc=none smtp.remote-ip=209.85.210.181 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC510606A32D for ; Thu, 3 Dec 2026 13:38:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC510606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Dh7UlAkO Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-8a0880a46e7so627868b3a.1 for ; Thu, 03 Dec 2026 05:38:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796305104; x=1796909904; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=H8GKBuXvIFJH/OgoS1akZt0kffQzR9y9nIKZM/ekhhI=; b=Dh7UlAkOarpQBflQ7SSlb8/H8x2wpryG1ZKi9VuW9TFZrRJ5kFCM3W1TQqgDjVeQZC eK/lGL5ewdfEbjl9WaQzl9U+C6AS4AlORz8lt27xMEkXV0pHgIu3ErXJBEZwnz2xvEt0 xBuqsmYqh6LzsVCJm/ogvKU6OEmQBUimRq/RwLjxVV5RSNNQUcoZGnMZa/O06fshd6jk QMrFsMlhFeOnWj7PyGAPDM4tykOYTnc5269Dpwgcek+pnU992lkxv3LMzs3n2HQUnE6u yU1lWTqudzc9X67GAR6FeXCTYM4rRw8xw+e4Lmc82830jQ+yLX1ZoDz9e5h3lvzDXL3q NXEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796305104; x=1796909904; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=H8GKBuXvIFJH/OgoS1akZt0kffQzR9y9nIKZM/ekhhI=; b=JcnQWjbn9pezR5+KB8cxKLExk+BYEBCfrvahrAPzwTt00qGePqdqfEHeT5io0vU6aR fPtlDfOM1Zk5Ebbe7h26zIceMG6T59PPEf1dL/dhqMGAPYd03nSCb0cUtWuECbISsgr1 HbqmZWvWuyURcx6hr6b+vJe0piMyzLFCF2viOvm8CQ9Ed+58sE3SqqmA9+uR/fclFJx4 HFPAj0PHPAyorGjNuRMc8uU+H8FE2F/KGwQDosKAhfnKDfdh05R8eb7zHzaweMTukosa JPy8WD3eEqxLltXtHEjWcj9MSdw9lHevUlos9CkF0/3jsw2CaKg/aMpUcBn5KaLptAIP jewQ== X-Forwarded-Encrypted: i=1; AL+hErGXJNrZYPKhHuc6/Ch6xSs+xlUY6HwDejd+2GXVYbU55Fs019xteRjgovSTWYj4WxPKbUQ=@vger.kernel.org X-Gm-Message-State: APuU4Z8rlj5pL/v5Yc5cSWqRp1GYsEhRWGS0tTnFh5UVln1GxEB3+Hut /oeA9xQliFsBU1ToxZONTt7barszaqqxzagAr5ggSHA3Mv13clhjGwQL0pyk7w== X-Gm-Gg: AZFdTZdZETLIXUZPh8vZ0DBCQfpoA8MRUqYYMRph3I6YNHI7Kfgt8yI1RpN7hZfDa7u C54dTU9kCX99FFyIWZEXuvigipsivcwzYiQ0ST9o3L+BG+JLckBBve6jnkhaeMt8e+Pi3oVhlw/ FFBLCA/ilohmzagupgT1pDW+G/kl8Suh9cuFGwUJc54MvoTCOUYg1vuLGtSvtFntFd56omINFK0 I9bnqD4t5uxGbOc2RaD4Os/RQsbQw4dmoc320OY6a+abrtkY/8frsL8eFmFhcQfWNTXSZFHkdsO iUykLGFdcGEBqo5fiOmT7409j4oKtqKDLVyqh7hV3M8cbOduUIYV2Rbci3Atk3HCIaPjlY0D6od Xlh9xVhpXJTEw/1vJU1DCe3Jhz2Z9xaUAG2eGOoK70wzsKUn/7xNd7FJ+943NbOtOS351Qa2S+f 5thWIeq03wEJbuLtda9CZz+xNniircVgGDAGcvdPihRrIeQVSRotUdmbE6w55cZOmcB+MdLyNSr xZ7Ls6FxWgIZmuB2LwEeoci6ZljSa52yaYKswMTgqeCiQjixCpldpa4Bms9fRgfaysx66dH6C/v WReng0sOlB42gDRmK7TF+84gXeovBw+T8GezF60mxg== X-Received: by 2002:a05:6a00:3e16:b0:89f:526f:d6cf with SMTP id d2e1a72fcca58-8dcce0745c0mr1425519b3a.42.1796305103805; Thu, 03 Dec 2026 05:38:23 -0800 (PST) Received: from [192.168.1.34] ([103.215.237.233]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87285c89dsm23427775b3a.13.2026.12.03.05.38.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Dec 2026 05:38:23 -0800 (PST) Message-ID: Date: Thu, 3 Dec 2026 19:08:20 +0530 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 5/7] commit-graph: decide mergeable and chainable layers by depth To: Patrick Steinhardt Cc: Junio C Hamano , git@vger.kernel.org References: <20261120-pks-odb-pluggable-commit-graphs-v2-0-31f2341a9932@pks.im> <20261120-pks-odb-pluggable-commit-graphs-v2-5-31f2341a9932@pks.im> Content-Language: en-US From: Kaartic Sivaraam In-Reply-To: <20261120-pks-odb-pluggable-commit-graphs-v2-5-31f2341a9932@pks.im> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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. > 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. */ > > + /* > + * 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? > + 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. [...] */ > + > + if (mergeable) > + ctx.mergeable_layers++; > + ctx.chainable_layers++; > + } > + > if (opts->flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS) > ctx.changed_paths = 1; > if (!(opts->flags & COMMIT_GRAPH_NO_WRITE_BLOOM_FILTERS)) { > -- Sivaraam