🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4026

Re: [PATCH v3] test-lib: run EXPENSIVE tests one at a time

#4026
From: Kaartic Sivaraam
Date: Sat, 28 Nov 2026 08:06
98 lines
14712 bytes
On 11/28/26 02:16, Junio C Hamano wrote:
> Kaartic Sivaraam <kaartic.sivaraam@gmail.com> writes:
> 
>> Recently, we've acquired quite a few expensive tests in our test suite.
>> For instance, these commits add several tests that require
>> multi-gigabytes of memory:
> 
> Either "multi-gigabyte" or "multiple gigabytes"?
>

Good catch. Will fix it.

>> GitHub CI runners are no exception and observe the same behaviour.
> 
> Pedantic.  You "observe" that runners "experience/suffer from/trigger".
> They do not observe themselves ;-).
> 

Ah. Thanks for correcting my grammar. Will fix this too :-)

> Minor ordering observation.  Because "trap die EXIT" is registered right
> after die(), well before fail_117() where release_expensive_lock_() is
> defined, an early failure while sourcing test-lib-functions.sh under set
> -e would enter die() while release_expensive_lock_() is still undefined.
> 
> I notice that "$expensive_lock_" already has a test -z guard here, and
> that would help avoid such issues to some degree.  Defining the lock
> variables and helpers above die() (or guarding the call) would close
> that small window.
>

That's an interesting one. I've defined it above die() per your suggestion.

>> +acquire_expensive_lock_ () {
>> +	local owner waited= tmp="$expensive_lock_.$$" misses=0
>> +	mkdir -p "$TEST_RESULTS_DIR" || return 1
>> +	# The lock is a hard link to a file that already holds our PID, so
>> +	# it never exists without its owner recorded in it. Remove any
>> +	# $tmp left by a dead process with our PID first: it may still be
>> +	# linked to that process's lock, which writing to it would empty.
>> +	rm -f "$tmp"
>> +	echo $$ >"$tmp" || return 1
> 
> This pre-cleanup and hard-link scheme is neat.  Removing any leftover
> "$tmp" before writing "$$" keeps us from truncating the inode of a stale
> lock still hard-linked to an old "$tmp" from a recycled PID, and
> hard-linking after writing "$$" guarantees $expensive_lock_ never exists
> empty.
> 
> One minor consistency note.  When ln(1) fails three times with no lock
> present, acquire_expensive_lock_() prints "cannot take the EXPENSIVE
> lock, running anyway" to FD 3, removes "$tmp", and returns 0.
> 
> If mkdir or redirecting to "$tmp" fails instead (say, a read-only
> TEST_RESULTS_DIR or a full disk), it returns 1 silently and leaves an
> empty "$tmp" behind on write failure until die() runs.  Because
> test_run_() ignores the return value, the test still runs anyway as
> documented, though sharing the same cleanup, message, and return 0 would
> keep all fallback paths consistent.
> 

That's a good point. Will make the fallback paths consistent.

>> @@ -1103,6 +1170,12 @@ test_run_ () {
>>   		fi
>>   	fi
>>   
>> +	case ",$test_prereq," in
>> +	*,EXPENSIVE,*)
>> +		acquire_expensive_lock_
>> +		;;
>> +	esac
> 
> Because test_expect_success() and test_expect_failure() call test_skip()
> first, skipped tests never enter test_run_(), and the chainlint dry-run
> above this block runs before we take the lock.  Placing the lock around
> test_eval_() and outside its set -x block also keeps the polling loop
> out of -x trace logs under CI --verbose-log -x, while still releasing
> the lock before _error_exit() on --immediate failures.
> 
> Optional thought.  A small subtest in t/t0000-basic.sh seeding a stale
> expensive.lock with a dead PID or "$$" and checking that it is cleared
> and released (including under --immediate) could give quick regression
> coverage without any sleep delay.
>

Let me give this a shot. I'll keep it in a separate patch so that we 
could discuss it separately.

> Overall this is clean and well thought out.
> 
> Very nice.

That's good to hear :-)

-- 
Sivaraam
Technical Details
Message-ID: <46b303b9-cf58-4c4b-9d2d-07f4c1ce0dc0@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.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-76579-linux-kernel-git=dewy.ru
References: <20261119-ks-ci-long-test-hang-fix-v1-1-45c2fff6d9f0@gmail.com> <20261127-ks-ci-long-test-hang-fix-v3-1-91b2aac82a1c@gmail.com> <xmqqpkvq6lzy.fsf@gitster.g>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-76579-linux-kernel-git=dewy.ru
From: kaartic.sivaraam@gmail.com (Kaartic Sivaraam)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v3] test-lib: run EXPENSIVE tests one at a time
Date: Sat, 28 Nov 2026 13:36:54 +0530
Organization: Usenet Network
Message-ID: <46b303b9-cf58-4c4b-9d2d-07f4c1ce0dc0@gmail.com>
References: <20261119-ks-ci-long-test-hang-fix-v1-1-45c2fff6d9f0@gmail.com>
 <20261127-ks-ci-long-test-hang-fix-v3-1-91b2aac82a1c@gmail.com>
 <xmqqpkvq6lzy.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="909994"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pZ4S3z4jLL1GITCqO9hMlDRbVVo= sha256:7I8a8c0wemYJq7rEb4hKg8JU76mw4W+tYxODT6xBIow=
	sha1:WHErRdqabI+y0JN8v7bduI64kwo= sha256:4/v9X0/3NLASS8AWN5HUsu30uuGJEEJv+D+t9+YEc4E=
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 1CDE3125F77; Sat, 28 Nov 2026 11:07:18 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.049
X-Spam-Status: No, score=-2.049 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.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.249,
	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 ehLt3RNwYl0e;
	Sat, 28 Nov 2026 11:07:15 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-76579-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id D5C9E125F70; Sat, 28 Nov 2026 11:07:04 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id EBF08603C2C; Sat, 28 Nov 2026 08:07:03 +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=1795853221;
	b=Pf3q3f7GgUzEEd0o47PqSV1Q7E36wg1nyHrGTHtF0VoxJaPFA7rbdzDm9ifsuBOcPpbU
	 F+uOsEy4GNVuSmjiph3MIfUVSdRaZkTXwYXEvArvInSqn9Qrj9s+wbdRcPotmD8xcdbXK
	 c2LXTPOdRfPYsz4v0Z5lPR3saDB1m+JALlNu55jRjMUV3zidP5CMKk+r3m5ywEQlihS8B
	 QVnMzStL0WVBet15o03yjQJyZWkUZaQELSzuBPcMVdmaF5NJdgsJ7NHiwDJkFbQ5K36mE
	 AJp+SWdB+12mGl9ByhnaaVmcryrpgFFZ4ZXn+nFmoE3ovLt9089XlYdeajSFe1EPdFw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795853221;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature: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=O0Dg0/RTxO7uA3scJ93EtYyWBhG/t5TUCKlvFrwNbmU=;
	b=ymM7WDQWNzUOMJLsw6NEvo6SmwipjIZ7V0ocPBHSw+jX0N707Rt7F45+lVoZs+JUYGzm
	 B8S28zpL+FvB4RWLWvJhS4dfwetGlRPzHDjYkU4n/kDzOZv4oUAuozRRFsY97ecIyi/Vr
	 5JVRDsS0RfBP6yEw+yEGkV5hWwb1MMbW+mUS+KEg7Y+5+n6AIJt8DBfUxbXe8Vu94B1AF
	 UN4uT6E1YQS/lqjobFGAIbnTh/lBJmPBTJf2dpyNtrlRUFgpQ0wBpxGyPYldYWDUpZdZ3
	 j0ti0wRfmaf20fYOy4DntldGFwTOdSHT3zcYa/4wyT46YsmtPM6F3wbPFy/hqPGA1tw==
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=bYcpBm7k;
	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 1B2DB606A327;
	Sat, 28 Nov 2026 08:07:01 +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=bYcpBm7k
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.178
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795853220;
	b=d3nZgrumCr8GPVo17/wouqmug3xWuN66pO3t79+w/mm+5agaksNel/5Kb6UPJ/jGdaRE
	 pjpm0xKYxqQRcbC6zN3nIC6uHA3zdaoQQIXn/nqpdhMl1+uElHJNlyLL7gUz3eVqnra2v
	 0aR7l83TrzKAL7VMMuruEzC+EyblCMj/wpE6IDwEPQyWeRPmPMpGjkOmECy8hoCDrtSsx
	 yHzxmqDo/5pzHLG0GezTxPv1IvIfuGk1aLuq0ouAOkztQusnV0J3fYtxwL6BaXkbBmW3D
	 JKXaII5xtQSTjcBEDOEHqDndmpnd4s3QPmf/FpztvhXFpwR4OGTufvDe2k1A8Oh3SCQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795853220;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 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=O0Dg0/RTxO7uA3scJ93EtYyWBhG/t5TUCKlvFrwNbmU=;
	b=uoLmwVRF/bnniVprFjU1JzIEpms2cN+ojD2P3PfTBnjfUKptvrHKmV9hutS7/UlVqjjx
	 g8bmykd56qpp4Z9qZ/7kgTl+DbvxvEl878p27TDUMpGUS5hdgRdiYfrkuvEfcLEpwInVF
	 FQI2WJJuusCrdawvxTDRZZd+ZouGJhTJQfbybCvlVWFSrTRLEEvyHS5QOpiNWeUc+QI+b
	 QMZ0SBNJ33/zUdtHRVoVJTKgqsNAfO4FWIdzksEI2BQeE8js6gXVkhVVaLwOK6wjEyeDv
	 8CESHe6J+8B8fELSW0yBSNF1UXdbyFNqE6bzqn4TAPVmhVO5nUvkiELgjXy5cgyqqRw==
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=bYcpBm7k;
	arc=none smtp.remote-ip=74.125.82.178
X-Received: from mail-dy1-f178.google.com (mail-dy1-f178.google.com [74.125.82.178])
	(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 DB989606A31C
	for <git@vger.kernel.org>; Sat, 28 Nov 2026 08:06:59 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DB989606A31C
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-dy1-f178.google.com with SMTP id 5a478bee46e88-33fb4680717so6454590eec.1
        for <git@vger.kernel.org>; Sat, 28 Nov 2026 00:06:59 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1795853219; x=1796458019; 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=O0Dg0/RTxO7uA3scJ93EtYyWBhG/t5TUCKlvFrwNbmU=;
        b=bYcpBm7kWKDGr0hgOLC9cqjQqNj7Xv/tL8XWhzF8jcbseSlcg4Jh3JBlaXJMliEDUL
         4cbtRbwVEFO4wuTeyd7v2bzkSBmAwCERnEjLVpMLFxI+WNHwdZ1JOBoIBJKVOZt3Dv+w
         Sfv36daQARkgAICNAAN7TGG8EQHYS8wfqZ3KsTjksB6I9wn46WtBS1HmPq/TYyxamiLd
         5SITOJRPfbBITO3ywjL2bclrtme6z5zarso+lJRTjLHeK/pPbbx8zCV07/+CZvJJZDnn
         wN5qxJkDR4zo0wmorP3bQMYjuXckjnkWowUnja6K1u+A3pbtmPLebzKX1LnEnR2xQcZZ
         mejA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1795853219; x=1796458019;
        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=O0Dg0/RTxO7uA3scJ93EtYyWBhG/t5TUCKlvFrwNbmU=;
        b=H/oBrClLbHMydmXUCrjqLo+qTPnl/9V4YwYkLXDlfV8DThB10OZazxSmxdf4Ri4UnM
         VDaQNMKQSSQe8bpQD7Joib4MMuW5iNgWt78yU0+6XSq4y6W8Zu5qvN3Of8t4rxr0ticj
         XpM/hRKg2R3d+1vZRuqQhZCygh/K23Zg37nCQK+RcjN+4bdDTwVWPh7E5aWhaYpfGtQa
         opkh/5h8NO8DEcRyLFtFuQc3e1CPFQLgt1mQNzvWoEiH9cwsEzfko+scKF5hFwF9YqXI
         EavWq23j3DJxwX9VlbCgWNe4f2JbOvEjmnW5GKBQpbOMbHqWujpwyinhYqodbpuRAT5B
         oO4A==
X-Gm-Message-State: APuU4Z9WX0OAeeCwQ6t8DZKvexMZRW4sH6FG3L9nCdzzE9WTz2bsOkeh
	5/GcRqHyo3J9yZV0y0pYY/QKBhdcIbIgyuOykf4U26qP6hBBjlDS7yu7
X-Gm-Gg: AZFdTZeufZ5DR8PUrUsRwrUf2XqCpP3XAKqCR5eQaAt/zF43CfPU0XPrA7rOiTMT+A2
	qyFVjBmo6audZ3GywqlnVU6RZkOGVb6xGaEo9gVk4OP9xV0SAhn3HOJw1YYYYkTIzPH6lPXjObC
	e/wAaAQ7Uydw52pAxiKZ3fxk506n1LHzCjClpsQcQ/ycFgSbVH2ws7lsl0QVlVxgxw6tOqvF4hd
	iORM45LhUJjhdkhiOABs3TTM9b+hzP11DsBOdIS6njwLkGjtqsW/PN36nLsYNsGM9zxegRo3rnA
	eXgK7F42FwKmAL9nX4iAtcsQPXpUkmJWQhbyQ2pP/lL1HUuE67sV427JWQkYHhc6vqpm4whiTOM
	2wzQQxoQXed26sIgZ1qYpgxdZqh2yBv9i00XW4A/8N1qo1aSfo7Bt0EBsKMAz55l1eVpF+4czqR
	aui/Mti743gFI0bE/2Qw+Wm7qIMkQUn29YVfQlS8kgEPz3NvvTa2xnO5Ocq0H3Dbprn6CV5by/C
	Q6uYITrMf73gAVxuqlr62QPdijnV9BDYBGjj8TivZWaka5WFLStwfX/0zCoq9A2yot0K6UW3Geh
	SdqOKa9A9so9Hka2pXiTIA6CNj3j5A3Zvk8BtCOCtQVApy87z0/3ZMsxtrSx6q/q2xf2+Iq3jM/
	gdt1TK1Nz
X-Received: by 2002:a05:693c:65c3:b0:386:e9bb:d9d3 with SMTP id 5a478bee46e88-386e9bbda7dmr5277984eec.28.1795853218835;
        Sat, 28 Nov 2026 00:06:58 -0800 (PST)
X-Received: from ?IPV6:2406:7400:12b:ed80:211c:a254:fe90:c295? ([2406:7400:12b:ed80:211c:a254:fe90:c295])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38567cafec4sm90008610eec.26.2026.11.28.00.06.56
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Sat, 28 Nov 2026 00:06:58 -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: Git mailing list <git@vger.kernel.org>,
 Harald Nordgren <haraldnordgren@gmail.com>
X-In-Reply-To: <xmqqpkvq6lzy.fsf@gitster.g>