From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:46579) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOlPb-0001Jy-U3 for guix-patches@gnu.org; Sun, 27 Oct 2019 12:29:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOlPa-0001RK-UL for guix-patches@gnu.org; Sun, 27 Oct 2019 12:29:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34609) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iOlPa-0001RC-LM for guix-patches@gnu.org; Sun, 27 Oct 2019 12:29:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iOlPa-0004GA-FK for guix-patches@gnu.org; Sun, 27 Oct 2019 12:29:02 -0400 Subject: [bug#36630] [PATCH] use two threads to build man-pages and secure output msgs with mutex References: <20190712214245.23857-1-arne_bab@web.de> In-Reply-To: <20190712214245.23857-1-arne_bab@web.de> Resent-Message-ID: From: Arne Babenhauserheide Date: Sun, 27 Oct 2019 17:27:57 +0100 Message-Id: <20191027162757.32295-1-arne_bab@web.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arne_bab@web.de Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 36630@debbugs.gnu.org Cc: Arne Babenhauserheide =2D-- guix/profiles.scm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index a0ae9a4c7e..9d2133df2d 100644 =2D-- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1315,11 +1315,18 @@ the entries in MANIFEST." (ice-9 threads) (srfi srfi-1) (srfi srfi-19)) + ;; ensure conflict free user-output + (define status-output-mutex (make-mutex)) + + (define (status-message msg) + (lock-mutex status-output-mutex) + (display msg) + (unlock-mutex status-output-mutex)) (define (compute-entry directory count total) - (format #t "\r[~3d/~3d] building list of \ + (status-message (format #f "\r[~3d/~3d] bui= lding list of \ man-db entries..." - count total) + count total)) (force-output) (let ((man (string-append directory "/share/man"))) @@ -1332,7 +1339,9 @@ man-db entries..." ;; decompression), so report progress as we traverse INPUTS= . (let* ((inputs '#$(manifest-inputs manifest)) (total (length inputs))) - (apply append (par-map compute-entry + ;; experimenting shows that two threads suffice to remove= most + ;; waiting + (apply append (n-par-map 2 compute-entry inputs (iota total 1) (make-list total total))))) =2D- 2.23.0