emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#37510: closed ([PATCH 1/1] compile: Fix race condi


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#37510: closed ([PATCH 1/1] compile: Fix race condition on completion progress.)
Date: Sat, 28 Sep 2019 04:02:02 +0000

Your message dated Sat, 28 Sep 2019 00:01:08 -0400 (EDT)
with message-id <address@hidden>
and subject line Re: [bug#37510] [PATCH 1/1] compile: Fix race condition on 
completion progress.
has caused the debbugs.gnu.org bug report #37510,
regarding [PATCH 1/1] compile: Fix race condition on completion progress.
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
37510: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=37510
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: [PATCH 1/1] compile: Fix race condition on completion progress. Date: Tue, 24 Sep 2019 21:07:06 -0500
From: Eric Bavier <address@hidden>

This prevent a race condition where multiple compilation threads could report
the same completion.

* guix/build/compile.scm (compile-files)<completed>: Increment in same mutex
region as the compilation is reported.


Further reading:

When compiling many scheme files, or with '-j1', this is not usually a
problem, but with multiple build jobs and a handful of scheme files to update,
you may encounter unexpected output.  E.g. I recently saw this from `make -j2`:

```
Compiling Scheme modules...
[ 25%] LOAD     gnu/packages/haskell.scm
;;; note: source file ./gnu/packages/haskell.scm
;;;       newer than compiled /home/bavier/projects/guix/gnu/packages/haskell.go
;;; note: source file ./gnu/packages/haskell.scm
;;;       newer than compiled /home/bavier/projects/guix/gnu/packages/haskell.go
[ 50%] LOAD     gnu/packages/idris.scm
;;; note: source file ./gnu/packages/idris.scm
;;;       newer than compiled /home/bavier/projects/guix/gnu/packages/idris.go
;;; note: source file ./gnu/packages/idris.scm
;;;       newer than compiled /home/bavier/projects/guix/gnu/packages/idris.go
[ 75%] GUILEC   gnu/packages/haskell.go
[ 75%] GUILEC   gnu/packages/idris.go
make[2]: Leaving directory '/home/bavier/projects/guix'
make[1]: Leaving directory '/home/bavier/projects/guix'
```
---
 guix/build/compile.scm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/guix/build/compile.scm b/guix/build/compile.scm
index c127456fd0..f77e49340a 100644
--- a/guix/build/compile.scm
+++ b/guix/build/compile.scm
@@ -173,7 +173,8 @@ files are for HOST, a GNU triplet such as 
\"x86_64-linux-gnu\"."
 
   (define (build file)
     (with-mutex progress-lock
-      (report-compilation file total completed))
+      (report-compilation file total completed)
+      (set! completed (+ 1 completed)))
 
     ;; Exit as soon as something goes wrong.
     (exit-on-exception
@@ -185,9 +186,7 @@ files are for HOST, a GNU triplet such as 
\"x86_64-linux-gnu\"."
                          #:output-file (string-append build-directory "/"
                                                       (scm->go relative))
                          #:opts (append warning-options
-                                        (optimization-options relative)))))))
-    (with-mutex progress-lock
-      (set! completed (+ 1 completed))))
+                                        (optimization-options relative))))))))
 
   (with-augmented-search-path %load-path source-directory
     (with-augmented-search-path %load-compiled-path build-directory
-- 
2.23.0




--- End Message ---
--- Begin Message --- Subject: Re: [bug#37510] [PATCH 1/1] compile: Fix race condition on completion progress. Date: Sat, 28 Sep 2019 00:01:08 -0400 (EDT)

----- On Sep 26, 2019, at 3:57 PM, Ludovic Courtès address@hidden wrote:

> Eric Bavier <address@hidden> skribis:
> 
>>>> +++ b/guix/build/compile.scm
>>>> @@ -173,7 +173,8 @@ files are for HOST, a GNU triplet such as
>>>> \"x86_64-linux-gnu\"."
>>>>  
>>>>    (define (build file)
>>>>      (with-mutex progress-lock
>>>> -      (report-compilation file total completed))
>>>> +      (report-compilation file total completed)
>>>> +      (set! completed (+ 1 completed)))
>>> 
>>> Here ‘completed’ is incremented before the thing is even started.
>>
>> Maybe a more generic name like "progress" would be appropriate?
> 
> Yes, probably!

Ok, pushed with a rename to "progress" in commit 21391f8c83.

-- 
`~Eric


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]