guix-patches
[Top][All Lists]
Advanced

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

[bug#37510] [PATCH 1/1] compile: Fix race condition on completion progre


From: Ludovic Courtès
Subject: [bug#37510] [PATCH 1/1] compile: Fix race condition on completion progress.
Date: Thu, 26 Sep 2019 11:28:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hello,

address@hidden skribis:

> 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

I think it’s expected: it shows completion at the time we started to
build these files.  Compilation of haskell.scm and idris.scm started at
the same time, and at that point we had built 75% of the files.  I agree
it’s confusing though.  :-)

> +++ 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.

Anyway, LGTM!  :-)

Ludo’.





reply via email to

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