From patchwork Sun Mar 24 21:23:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 1566 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 5751816DCF; Sun, 24 Mar 2019 21:24:06 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id EE1C016DCB for ; Sun, 24 Mar 2019 21:24:05 +0000 (GMT) Received: from localhost ([127.0.0.1]:60916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Ab7-0004fj-JH for patchwork@mira.cbaines.net; Sun, 24 Mar 2019 17:24:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Ab5-0004fE-7H for guix-patches@gnu.org; Sun, 24 Mar 2019 17:24:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8Ab4-0007op-58 for guix-patches@gnu.org; Sun, 24 Mar 2019 17:24:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:43661) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h8Ab3-0007oH-V0 for guix-patches@gnu.org; Sun, 24 Mar 2019 17:24:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h8Ab3-0004NZ-R5 for guix-patches@gnu.org; Sun, 24 Mar 2019 17:24:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#34982] [PATCH] guile-build-system: Support building in parallel. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 24 Mar 2019 21:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 34982 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34982@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.155346264116825 (code B ref -1); Sun, 24 Mar 2019 21:24:01 +0000 Received: (at submit) by debbugs.gnu.org; 24 Mar 2019 21:24:01 +0000 Received: from localhost ([127.0.0.1]:57205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h8Ab2-0004NJ-Op for submit@debbugs.gnu.org; Sun, 24 Mar 2019 17:24:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h8Ab1-0004N5-0h for submit@debbugs.gnu.org; Sun, 24 Mar 2019 17:23:59 -0400 Received: from lists.gnu.org ([209.51.188.17]:42918) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h8Aav-0007SE-Sd for submit@debbugs.gnu.org; Sun, 24 Mar 2019 17:23:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Aau-0004et-LJ for guix-patches@gnu.org; Sun, 24 Mar 2019 17:23:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8Aar-0007Pv-0O for guix-patches@gnu.org; Sun, 24 Mar 2019 17:23:50 -0400 Received: from li622-129.members.linode.com ([212.71.249.129]:48220 helo=mira.cbaines.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Aap-0007Ny-6p for guix-patches@gnu.org; Sun, 24 Mar 2019 17:23:48 -0400 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 5DB1D16DCA for ; Sun, 24 Mar 2019 21:23:45 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 1817ac54 for ; Sun, 24 Mar 2019 21:23:45 +0000 (UTC) From: Christopher Baines Date: Sun, 24 Mar 2019 21:23:45 +0000 Message-Id: <20190324212345.4697-1-mail@cbaines.net> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/build/guile-build-system.scm (build): Use n-par-for-each, instead of for-each, to use multiple cores if available. --- guix/build/guile-build-system.scm | 43 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/guix/build/guile-build-system.scm b/guix/build/guile-build-system.scm index 0bed049436..a5741081bf 100644 --- a/guix/build/guile-build-system.scm +++ b/guix/build/guile-build-system.scm @@ -23,6 +23,7 @@ #:use-module (ice-9 match) #:use-module (ice-9 popen) #:use-module (ice-9 rdelim) + #:use-module (ice-9 threads) #:use-module (guix build utils) #:export (target-guile-effective-version %standard-phases @@ -101,24 +102,32 @@ Return #false if it cannot be determined." (match (getenv "GUILE_LOAD_COMPILED_PATH") (#f "") (path (string-append ":" path))))) - (for-each (lambda (file) - (let* ((go (string-append go-dir - (file-sans-extension file) - ".go"))) - ;; Install source module. - (install-file (string-append source-directory "/" file) - (string-append module-dir - "/" (dirname file))) + (n-par-for-each + (parallel-job-count) + (lambda (file) + (catch #t + (lambda () + (let* ((go (string-append go-dir + (file-sans-extension file) + ".go"))) + ;; Install source module. + (install-file (string-append source-directory "/" file) + (string-append module-dir + "/" (dirname file))) - ;; Install and compile module. - (apply invoke guild "compile" "-L" source-directory - "-o" go - (string-append source-directory "/" file) - flags))) - - ;; Arrange to strip SOURCE-DIRECTORY from file names. - (with-directory-excursion source-directory - (find-files "." scheme-file-regexp))) + ;; Install and compile module. + (apply invoke guild "compile" "-L" source-directory + "-o" go + (string-append source-directory "/" file) + flags))) + (lambda (key . args) + ;; Since ports are not thread-safe as of Guile 2.0, reopen stderr. + (let ((port (fdopen 2 "w0"))) + (print-exception port #f key args) + (primitive-exit 1))))) + ;; Arrange to strip SOURCE-DIRECTORY from file names. + (with-directory-excursion source-directory + (find-files "." scheme-file-regexp))) #t)) (define* (install-documentation #:key outputs