From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:53833) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDU2x-0006sJ-6R for guix-patches@gnu.org; Thu, 26 Sep 2019 09:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDU2w-0002VX-2c for guix-patches@gnu.org; Thu, 26 Sep 2019 09:43:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34142) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDU2v-0002VD-VV for guix-patches@gnu.org; Thu, 26 Sep 2019 09:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iDU2v-0003ou-RY for guix-patches@gnu.org; Thu, 26 Sep 2019 09:43:01 -0400 Subject: [bug#37510] [PATCH 1/1] compile: Fix race condition on completion progress. Resent-Message-ID: Date: Thu, 26 Sep 2019 09:42:45 -0400 (EDT) From: Eric Bavier Message-ID: <58295170.37303056.1569505365844.JavaMail.zimbra@centurylink.net> In-Reply-To: <87pnjnpfsz.fsf@gnu.org> References: <20190925020706.6034-1-ericbavier@centurylink.net> <87pnjnpfsz.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 37510@debbugs.gnu.org, bavier ----- On Sep 26, 2019, at 4:28 AM, Ludovic Court=C3=A8s ludo@gnu.org wrote: > Hello, >=20 > ericbavier@centurylink.net skribis: >=20 >> From: Eric Bavier >> >> This prevent a race condition where multiple compilation threads could r= eport >> the same completion. >> >> * guix/build/compile.scm (compile-files): Increment in same m= utex >> 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 u= pdate, >> you may encounter unexpected output. E.g. I recently saw this from `mak= e -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/ha= skell.go >> ;;; note: source file ./gnu/packages/haskell.scm >> ;;; newer than compiled /home/bavier/projects/guix/gnu/packages/ha= skell.go >> [ 50%] LOAD gnu/packages/idris.scm >> ;;; note: source file ./gnu/packages/idris.scm >> ;;; newer than compiled /home/bavier/projects/guix/gnu/packages/id= ris.go >> ;;; note: source file ./gnu/packages/idris.scm >> ;;; newer than compiled /home/bavier/projects/guix/gnu/packages/id= ris.go >> [ 75%] GUILEC gnu/packages/haskell.go >> [ 75%] GUILEC gnu/packages/idris.go >=20 > I think it=E2=80=99s 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=E2=80=99s confusing though. :-) Right. If we did indeed expect to see completion at the time we started, t= hen I would expect to see "0%" displayed with the first "LOAD". >=20 >> +++ b/guix/build/compile.scm >> @@ -173,7 +173,8 @@ files are for HOST, a GNU triplet such as >> \"x86_64-linux-gnu\"." >> =20 >> (define (build file) >> (with-mutex progress-lock >> - (report-compilation file total completed)) >> + (report-compilation file total completed) >> + (set! completed (+ 1 completed))) >=20 > Here =E2=80=98completed=E2=80=99 is incremented before the thing is even = started. Maybe a more generic name like "progress" would be appropriate? >=20 > Anyway, LGTM! :-) Thanks for reviewing. --=20 `~Eric