🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3377

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

#3377
From: Kaartic Sivaraam
Date: Thu, 19 Nov 2026 07:40
152 lines
15562 bytes
Recently, we've acquired quite a few expensive test in our test suite.
For instance, these commits add several tests that require
multi-gigabytes:

  - 9048b48fb (t1600-index: add expensive tests for over-long
    tree paths, 2026-10-16) added tests to t1600

  - 288266c11d (xdiff: use size_t for merge buffer size computations,
    2026-10-16) added tests to t4300

  - 55c54fd375 (apply: reject binary patches greater than MAX_APPLY_SIZE,
    2026-03-25), added tests to t4141

We also have the memory hungry 5GB filtered hash-object test in t1007.

When GIT_TEST_LONG is set, "prove --jobs" happily runs several of these
at once. On the 16GB GitLab CI runners this exhausts memory: the
sanitizer jobs have been hanging in t1007 until they hit the job
timeout ever since the new EXPENSIVE tests in t1600 started running
alongside it. Running the two under a 16GB memory cap reproduces it,
with the t1007 git process getting OOM-killed.

GitHub CI runners are no exception and observe the same behaviour.

Take a lock shared by all test scripts around each EXPENSIVE test, so
only one of them runs at a time. The lock is a directory in
TEST_RESULTS_DIR, created with mkdir(1) like the existing valgrind
symlink lock. It records the holder's PID so that a lock left behind by
a script that was killed with SIGKILL gets taken over by the next
waiter. It is released after the test and its cleanup finish, and from
the EXIT trap when a script dies or is interrupted while holding it.

Cheap tests in the same scripts keep running in parallel. Only the
expensive ones wait for each other.

Signed-off-by: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
---
In recent times, we've been noticing the sanitizer jobs (linux-leaks,
linux-reftable-leaks, linux-asan-ubsan) hang and fail with timeout in
our GitLab CI runners. On some digging, it turns out that this is
because of multiple memory hungry tests running in parallel.

So, I thought of suggesting this patch to serialize the expensive tests
at least to avoid the putting the CI runners under memory pressure.

The GitHub CI runners also observed the same behaviour.

Both CI runners are happy with this change.

GitHub: https://github.com/sivaraam/git/actions/runs/43281285339
GitLab: https://gitlab.com/gitlab-org/git/-/pipelines/3079929506
---
 t/README      |  4 +++-
 t/test-lib.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/t/README b/t/README
index fd7e8504b5..c156dd3af6 100644
--- a/t/README
+++ b/t/README
@@ -117,7 +117,9 @@ appropriately before running "make". Short options can be bundled, i.e.
 -l::
 --long-tests::
 	This causes additional long-running tests to be run (where
-	available), for more exhaustive testing.
+	available), for more exhaustive testing. These tests can use a
+	lot of memory and disk, so only one of them runs at a time, even
+	when several test scripts run in parallel (e.g. "prove --jobs").
 
 -r::
 --run=<test-selector>::
diff --git a/t/test-lib.sh b/t/test-lib.sh
index c56654b7c5..4d29172c9d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -784,6 +784,7 @@ die () {
 	# test script run with '--immediate' fails, or when the user hits
 	# ctrl-C, i.e. when 'test_done' is not invoked at all.
 	test_atexit_handler || code=$?
+	release_expensive_lock_
 	if test -n "$GIT_EXIT_OK"
 	then
 		exit $code
@@ -1089,6 +1090,42 @@ fail_117 () {
 	return 117
 }
 
+# EXPENSIVE tests can need many gigabytes of memory or disk, so two of
+# them running at the same time under "prove --jobs" can exhaust the
+# machine. Allow only one at a time across all test scripts that share
+# this TEST_OUTPUT_DIRECTORY.
+expensive_lock_="$TEST_RESULTS_DIR/expensive.lock"
+have_expensive_lock_=
+
+acquire_expensive_lock_ () {
+	mkdir -p "$TEST_RESULTS_DIR" || return 1
+	while ! mkdir "$expensive_lock_" 2>/dev/null
+	do
+		owner=$(cat "$expensive_lock_/pid" 2>/dev/null)
+		if test -n "$owner" && ! kill -0 "$owner" 2>/dev/null
+		then
+			# The holder was killed without releasing the lock.
+			rm -rf "$expensive_lock_"
+			continue
+		fi
+		if test -z "$expensive_lock_waited_"
+		then
+			say >&3 "waiting for another EXPENSIVE test to finish"
+			expensive_lock_waited_=t
+		fi
+		sleep 1
+	done
+	expensive_lock_waited_=
+	echo $$ >"$expensive_lock_/pid"
+	have_expensive_lock_=t
+}
+
+release_expensive_lock_ () {
+	test -n "$have_expensive_lock_" || return 0
+	rm -rf "$expensive_lock_"
+	have_expensive_lock_=
+}
+
 test_run_ () {
 	test_cleanup=:
 	expecting_failure=$2
@@ -1103,6 +1140,12 @@ test_run_ () {
 		fi
 	fi
 
+	case ",$test_prereq," in
+	*,EXPENSIVE,*)
+		acquire_expensive_lock_
+		;;
+	esac
+
 	setup_malloc_check
 	test_eval_ "$1"
 	eval_ret=$?
@@ -1115,6 +1158,7 @@ test_run_ () {
 		test_eval_ "$test_cleanup"
 		teardown_malloc_check
 	fi
+	release_expensive_lock_
 	if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
 	then
 		echo ""

---
base-commit: e1ec09b23c8e0deb21a0b95ac5996422277395d4
change-id: 20261117-ks-ci-long-test-hang-fix-008e72fd40c6
Technical Details
Message-ID: <20261119-ks-ci-long-test-hang-fix-v1-1-45c2fff6d9f0@gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75794-linux-kernel-git=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75794-linux-kernel-git=dewy.ru
From: kaartic.sivaraam@gmail.com (Kaartic Sivaraam)
Newsgroups: linux.kernel.git
Subject: [PATCH] test-lib: run EXPENSIVE tests one at a time
Date: Thu, 19 Nov 2026 13:10:31 +0530
Organization: Usenet Network
Message-ID: <20261119-ks-ci-long-test-hang-fix-v1-1-45c2fff6d9f0@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network; logging-data="2819981"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:d2QMR+t2ffTDdPrbU1q/ltqk27w= sha256:9q9S/buYRs2arn9FWAl7yGHDmcoaELtG1Q39qTOxCL4= sha1:NPkAFijoawJLtMHuV1o1tP88x2o= sha256:AbmmVRyk1xI7TIDsCWiytVixXeRMFDm5ZLgiF8gSFxc=
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 C1236115552; Thu, 19 Nov 2026 10:41:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.148
X-Spam-Status: No, score=-3.148 tagged_above=-9999 required=6.31 tests=[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, URIBL_BLOCKED=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 oSQbk6xTq_Lm; Thu, 19 Nov 2026 10:41:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-75794-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 661E711554F; Thu, 19 Nov 2026 10:41:23 +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 29964186CEE; Thu, 19 Nov 2026 07:40:51 +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=1795074050; b=ek8NquJJByGVmPULHdvKyNQpW1G0EnWBmt0b8hXxxkiExmb+izf65wKumTIIc2Lql2JD Pr4XT2tRY1k2clEgnvHReVUw2wDaIwPbqzX+POkk+t5Et2e7o759p88zCRuvYpKu4OmN7 A81YN5L5XoY+NmQzeK7A1mYU4BlWM8k3Ro1JJf/t/5o1Xext9O2rsV4A6jP8yb2+EvqkB SSmMA9srqYw39rhpUibxflw3Wkc7f7NQlhpe57xd0NlJzbI2gSenekJJUbFKqiOScCeQe 91aUSbc2Cq0fuD+MqOltbG6olqLosoBOAKizZsvKlvd7a2yvM/O+ghHXSVLL82Zc09w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795074050; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received: Received:From:Date:Subject:X-Mailing-List:List-Id:List-Post:List-Help: List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer; bh=L656aHRm0NyqZzLDd1dJqJ/DLa09M4QOKKY60xV2V5Y=; b=A74heD4/qLUWW07ENGR3m0zgy67JKKAJ3Ixw/JUH562Uv+ohQ1GnVcDabkexfHJZ9Pxl lFFFsJ0iN03nJo4iA7fmz1svMY3jqoRHHaSV9ThpzdEGgCVZJmyG3I3tYsDaAbAXEsNIG PDjWE6NafoskQvr8h+uVE+JPEC+r9wgdqjuhhJ/aYaxx9iiq7SU31B8eoRl5HTqNIH6SE LlHdChg7qlquRrFwp5Gs2kqt4RzTZzW1Mb+cuVxL8mavfaDGWuU6gZ3evDDgTGz9sQcmu aDadc5R171mvIbAG+9TyTEFDRSRfGoiTec05BpvP1C9DGZtGjdP6HEzdfq4sEerKzKg==
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=I75DyXV0; 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 D5CE4606A32F; Thu, 19 Nov 2026 07:40:50 +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=I75DyXV0
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.174
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795074050; b=X5nHwuM1HBMPn9oPiuE+I42VSh5X2Sb3yY5kOsi2rE2ZKhnwNnMRg9IAjfGwvHwpRxo6 OZ/OOnAlCShOxRUCFlOmRq0MblWQD38MsCpHFfvIrB/L5a7RYgBNYraogCfZdH0i+ehja hEdpyZldbHRbvMyeIwUH93orGiSWAeJSqn8p9+aDn1Gmq5BK1K4SgSG5OWHVqUR9bfahy FvV72XboJ3j+hBQlUZEicU7Ov8PKdQwIotnP1M57+/6Jhca2/6X2DL+Z9axu3YkBAKSAf xCFUBn4hLuFVyD0hOooexwdZE22997a5Zu80XDbFzDZPgDBReu0gTJ+TI4nJKz/+E4A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795074050; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:Date:Subject: MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id: X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer; bh=L656aHRm0NyqZzLDd1dJqJ/DLa09M4QOKKY60xV2V5Y=; b=Pj7t5iXIR+eLmb2Pw0fdjKjgkf6vd8v5VTzaNAUhweCkN9ZNcc4xjaoN4IYHelVNxLLN jq7KGvXYSsAOYc/jPGc84E3SKytCyqIS+gV75oC23i5UajFkmKazhSz5rAUJlpmoKKs2K 9D0OGSlNcayf7MeXytA2Y9pebFdj96BWowxYaSftm+1MavGkI+H3DCiBnSKBcE82NvMYo OMZkPk/1IuVt8YjttF0LUT45zOMYNydWwdWyKaYXpdL/smn7ff//JKbB6CHT9Jk7eHFvG mIYNX4tc+hF0vwgPO6+TlVuDABZzfOmmhOiCRLReY4YGMHSWjdhWtzmmHv9IC0YomCg==
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=I75DyXV0; arc=none smtp.remote-ip=74.125.82.174
X-Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 160A4606A324 for <git@vger.kernel.org>; Thu, 19 Nov 2026 07:40:48 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 160A4606A324
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-f174.google.com with SMTP id 5a478bee46e88-380b40312e2so5296727eec.1 for <git@vger.kernel.org>; Wed, 18 Nov 2026 23:40:48 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795074048; x=1795678848; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=L656aHRm0NyqZzLDd1dJqJ/DLa09M4QOKKY60xV2V5Y=; b=I75DyXV0tl6BodBll7KJwxH0WRCCGujfqKfzMU7o5kzIRCF/4dfdFAkVlktb752JEu GlJP8yyPKi+IaPvgNMoeu9sr3Wus4STApVoIScoV06QoGeKLWDfmztvyCg+OkGtERt4o kCvylsG2VTVwmzqa7381yZ3eypPyZW08zPprlBteBgjjgkusReIHwXPvy+JL5w6Jt94/ tq/n0tPaeCsrjzCCR/Nsp6Yl3ahO11m6q3tTraQO7bJa0BYypc68eFykD3gv4N91+I9o yzuYxeEIjK3Y2vgOsOP9mcNzL/hs8MOqgehT5CBa7Khn258mVQ7zqglq4+hankd4kwMK Oq0w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795074048; x=1795678848; h=cc:to:message-id:content-transfer-encoding:content-type :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=L656aHRm0NyqZzLDd1dJqJ/DLa09M4QOKKY60xV2V5Y=; b=EO2wo2J7GObfBVQUTj9AbUy+ZShfCZjhL9n19mek2MGjP4wW6/9jzdM/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0:37f:73f9:aee7 with SMTP id 5a478bee46e88-3827da11e94mr5128011eec.5.1795074047948; Wed, 18 Nov 2026 23:40:47 -0800 (PST)
X-Received: from [127.0.1.1] ([106.51.27.147]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-382a45260a8sm25234574eec.3.2026.11.18.23.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 23:40:47 -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-B4-Tracking: v=1; b=H4sIAO+n/moC/yWMQQrDIBBFryKzzoBKSUqvErpIzJhOG7Q4JhQkd 6+2y/f57xUQSkwCN1Ug0cHCMVQwnQL3mMJKyEtlsNr2xpgBX4KOcYthxUySsZ3Q8we1vtJg/XL RroeqvxPV+Zce73+WfX6Sy60H5/kFoVe0MHwAAAA=
X-Change-ID: 20261117-ks-ci-long-test-hang-fix-008e72fd40c6
X-Cc: Patrick Steinhardt <ps@pks.im>
X-Mailer: b4 0.16.0
X-Received-Bytes: 15280