From 35226fcd055c8ae7146bc77e2902b72d0f285e5a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 4 Dec 2024 16:35:23 +0100 Subject: [PATCH] fix: create a more local lock when creating writable fixtures. Previously, the lock location would block all writers from executing a fixture even though they wouldn't step on each others feet. Now, a script destination is used to assure locks are created close to the destination when creating writable fixtures, typically removing the need for multiple writers to wait on each other unnecessarily. --- tests/tools/src/lib.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/tools/src/lib.rs b/tests/tools/src/lib.rs index 27fb06d5006..3f56a7ce549 100644 --- a/tests/tools/src/lib.rs +++ b/tests/tools/src/lib.rs @@ -509,11 +509,18 @@ fn scripted_fixture_read_only_with_args_inner( |d| (true, d.to_owned()), ); - let _marker = gix_lock::Marker::acquire_to_hold_resource( - script_basename, - gix_lock::acquire::Fail::AfterDurationWithBackoff(Duration::from_secs(6 * 60)), - None, - )?; + // We may that destination_dir is already unique (i.e. temp-dir) - thus there is no need for a lock, + // and we can execute scripts in parallel. + let _marker = destination_dir + .is_none() + .then(|| { + gix_lock::Marker::acquire_to_hold_resource( + script_basename, + gix_lock::acquire::Fail::AfterDurationWithBackoff(Duration::from_secs(6 * 60)), + None, + ) + }) + .transpose()?; let failure_marker = script_result_directory.join("_invalid_state_due_to_script_failure_"); if force_run || !script_result_directory.is_dir() || failure_marker.is_file() { if failure_marker.is_file() {