From b7ae89d8c1147e1ae7d2c176aa7ab902c951102c Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Fri, 16 Apr 2021 08:46:33 +0900 Subject: [PATCH] include/mutex: Use inotifywait to improve performance The current mutex implementation uses sleep to periodically check if the lock can be acquired. This causes a lot of latency for short waits and a lot of unnecessary sleep/wakeup cycles for long waits. This commit changes the mutex implementation to use inotifywait instead of sleep, increasing mutex performance for both short and long waits. --- include/mutex.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mutex.sh b/include/mutex.sh index 5760cfd..edc4da7 100644 --- a/include/mutex.sh +++ b/include/mutex.sh @@ -27,7 +27,7 @@ mutex_lock() { lock="$1" while ! mutex_trylock "$lock"; do - sleep 1 + inotifywait -qq "${lock%/*}" done return 0 -- 2.47.3