offload: Remove the "machine choice" lock.

This lock was unnecessary and it led to a contention when many 'guix
offload' processes are polling for available machines.

* guix/scripts/offload.scm (machine-choice-lock-file): Remove.
(choose-build-machine): Remove surrounding 'with-file-lock (machine-lock-file)'.
This commit is contained in:
Ludovic Courtès 2018-12-26 17:30:56 +01:00
parent b12f8720f5
commit 7f4d102c2f
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 51 additions and 58 deletions

View File

@ -453,10 +453,6 @@ of free disk space on '~a'~%")
(build-machine-name machine)
"." (symbol->string hint) ".lock"))
(define (machine-choice-lock-file)
"Return the name of the file used as a lock when choosing a build machine."
(string-append %state-directory "/offload/machine-choice.lock"))
(define (random-seed)
(logxor (getpid) (car (gettimeofday))))
@ -479,14 +475,11 @@ of free disk space on '~a'~%")
slot (which must later be released with 'release-build-slot'), or #f and #f."
;; Proceed like this:
;; 1. Acquire the global machine-choice lock.
;; 2. For all MACHINES, attempt to acquire a build slot, and filter out
;; 1. For all MACHINES, attempt to acquire a build slot, and filter out
;; those machines for which we failed.
;; 3. Choose the best machine among those that are left.
;; 4. Release the previously-acquired build slots of the other machines.
;; 5. Release the global machine-choice lock.
;; 2. Choose the best machine among those that are left.
;; 3. Release the previously-acquired build slots of the other machines.
(with-file-lock (machine-choice-lock-file)
(define machines+slots
(filter-map (lambda (machine)
(let ((slot (acquire-build-slot machine)))
@ -539,7 +532,7 @@ on disk space (~,2f MiB free)~%"
(release-build-slot slot)
(loop others)))))
(()
(values #f #f))))))
(values #f #f)))))
(define (call-with-timeout timeout drv thunk)
"Call THUNK and leave after TIMEOUT seconds. If TIMEOUT is #f, simply call