🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4306

Re: [PATCH v2 5/7] commit-graph: decide mergeable and chainable layers by depth

#4306
From: Kaartic Sivaraam
Date: Thu, 03 Dec 2026 13:38
104 lines
14829 bytes
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
Technical Details
Message-ID: <bac5e592-a060-40be-907c-384f79d46e7f@gmail.com>
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76957-linux-kernel-git=dewy.ru
References: <20261120-pks-odb-pluggable-commit-graphs-v2-0-31f2341a9932@pks.im> <20261120-pks-odb-pluggable-commit-graphs-v2-5-31f2341a9932@pks.im>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76957-linux-kernel-git=dewy.ru
From: kaartic.sivaraam@gmail.com (Kaartic Sivaraam)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v2 5/7] commit-graph: decide mergeable and chainable
 layers by depth
Date: Thu, 3 Dec 2026 19:08:20 +0530
Organization: Usenet Network
Message-ID: <bac5e592-a060-40be-907c-384f79d46e7f@gmail.com>
References: <20261120-pks-odb-pluggable-commit-graphs-v2-0-31f2341a9932@pks.im>
 <20261120-pks-odb-pluggable-commit-graphs-v2-5-31f2341a9932@pks.im>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2503959"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:rLslxbAAt7BS8DV3QJ70e3wyMkc= sha256:qR2dnxSKUv+DuJHIfavn8zkd+QiLDv1in0uZtzV0BmQ=
	sha1:tlM48DjUlQSemSkTGxuBpi95y/Y= sha256:yVuOPno50HI7UsaUGKMOoaHUwkI0Kgp1zhLlC/Ue8qE=
Content-Language: en-US
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6ACD0117966; Thu,  3 Dec 2026 16:38:39 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.197
X-Spam-Status: No, score=-2.197 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id el2Sf8_hgDzF;
	Thu,  3 Dec 2026 16:38:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76957-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A69EB117960; Thu,  3 Dec 2026 16:38:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 1FE4B282FD; Thu,  3 Dec 2026 13:38:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796305106;
	b=M94CbLIRqYwI/M/V75lxoRZfpo+CBMgfXU1xd6pDIxDpcaUUQsHz1djTv2ugxxJOzyBl
	 ne1RSQ5Dr3NqBl4dWHnEoHZVxM3a3NgAwC8QwzJN9U24+GXhFVIsqvr8Pb8Z0uySChMEN
	 uz7sPOiNbE5pgfDn4N1Agcm3N39xzZDs+VocbTwcTKtONEZAcsns/iQLM8pHxDqYnGjSv
	 w8ZvYdqG9/6YkxHyATRr9j5urBFBh9v62prdPCPCZokV3EcdOrKbJp71qVdKG/TbXraVH
	 yYmxSHOXTfTCz/AgS+xS459psM5CfFUfcC9yEVyTjd/UNYjX0NfFts8B0SHYJod/UEg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796305106;
	h=X-Original-To:Received: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:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:User-Agent:Subject:To:Cc:References:
	 Content-Language:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=H8GKBuXvIFJH/OgoS1akZt0kffQzR9y9nIKZM/ekhhI=;
	b=IgEGxoebZfBxn1yxbGT6YJ+RXp6TsyPLZbhmzXcXYU2TEyue2HZB61cG5qE1sWOTx/LY
	 BpQgeb23+7Pob5mxiFmClzRPRmvYI1hhB/lIobHiW2KzumyTDgrrrzXzhXUS8FyA3RKEW
	 t+8TFV/HKjdERC0DjnK0xhKr0OBWs2fhBHJE4zVZ5c6+TKEynZOQ1GPXqi/7ycIkmDPEM
	 tV0nHVyu/2FshqoxdEXh99fWtGPvKT2EgL7qz2WxY8P+kb+RrVCfHjd4eiMsUn/agzjsN
	 V3rGn2/72tYHgsSwUzVRcLdRYLCkFfzTpET9PDmf4vQflJf8zJzMQfHdeCZPqASre1Q==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Dh7UlAkO;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EB7E7606A336;
	Thu,  3 Dec 2026 13:38:25 +0000 (UTC)
X-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
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.181
X-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==
X-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==
X-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
X-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 <git@vger.kernel.org>; Thu,  3 Dec 2026 13:38:24 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC510606A32D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-8a0880a46e7so627868b3a.1
        for <git@vger.kernel.org>; Thu, 03 Dec 2026 05:38:24 -0800 (PST)
X-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)
X-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)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
X-In-Reply-To: <20261120-pks-odb-pluggable-commit-graphs-v2-5-31f2341a9932@pks.im>