GNU logs - #68271, boring messages


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#68271] [PATCH 0/3] Make some deduplicating speedups.
Resent-From: Christopher Baines <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Fri, 05 Jan 2024 20:51:02 +0000
Resent-Message-ID: <handler.68271.B.170448785315419 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 68271
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 68271 <at> debbugs.gnu.org
X-Debbugs-Original-To: guix-patches@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.170448785315419
          (code B ref -1); Fri, 05 Jan 2024 20:51:02 +0000
Received: (at submit) by debbugs.gnu.org; 5 Jan 2024 20:50:53 +0000
Received: from localhost ([127.0.0.1]:58025 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rLr9Z-00040d-Gw
	for submit <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:50:53 -0500
Received: from lists.gnu.org ([2001:470:142::17]:57158)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rLr9U-00040M-7T
 for submit <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:50:52 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mail@HIDDEN>) id 1rLr9I-0005Pb-R4
 for guix-patches@HIDDEN; Fri, 05 Jan 2024 15:50:37 -0500
Received: from mira.cbaines.net ([212.71.252.8])
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <mail@HIDDEN>) id 1rLr9H-0002ym-Ea
 for guix-patches@HIDDEN; Fri, 05 Jan 2024 15:50:36 -0500
Received: from localhost (unknown [217.155.61.229])
 by mira.cbaines.net (Postfix) with ESMTPSA id D1BE627BBE2
 for <guix-patches@HIDDEN>; Fri,  5 Jan 2024 20:50:33 +0000 (GMT)
Received: from felis (localhost [127.0.0.1])
 by localhost (OpenSMTPD) with ESMTP id ec58259b
 for <guix-patches@HIDDEN>; Fri, 5 Jan 2024 20:50:33 +0000 (UTC)
User-agent: mu4e 1.10.7; emacs 29.1
From: Christopher Baines <mail@HIDDEN>
Date: Fri, 05 Jan 2024 20:50:02 +0000
Message-ID: <87h6jrqzc7.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@HIDDEN;
 helo=mira.cbaines.net
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

--=-=-=
Content-Type: text/plain


Christopher Baines (3):
  guix: utils: Add delete-duplicates/sort.
  guix: derivations: Use delete-duplicates/sort.
  guix: packages: Speed up deduplicating inputs.

 guix/derivations.scm | 10 ++++++----
 guix/packages.scm    | 23 +++++++++++++++++++----
 guix/utils.scm       | 28 ++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 8 deletions(-)

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmWYa5hfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9Xd0ww//a5t0bHlFnCTiDMFqHSdw22JQ2UGs+HHb
Fu3n2KFmFBkmkcnRehpnm1AM3s5EvKPL54CIIgIa79feW3pvNPKov+tCLE8xszzg
lTjlEr8E3M8zr1kyfAgPwASZ1+DHmyIlfLeAViwnhLShx1Oj3tR5vIuLYdvrt4JA
5IRCSTnua7bleSm3zXOXaHFyblcau1EN64nD0z2lhBQXdzkyYfcr14+Qv/m7YlXH
NdaOTnpI51BkUTPEw1msH29/S2X2qGoju7hMEo6a5RCg/ZerCGR4kuKdyMqrueXP
XjhA4qTZZP/Bk4qx0SDq7vmGLG02bc03h4RUn0FUhK/6/bLbwU4VBJ3bppYPlSK5
kr8j0UmxgUUGBh6xcJ17ShkTc1F1+uIcjhpQKApQdH5It0IjTydMH+fabrW9ggOc
K3y/LWYRRp/ZO0vz9oMqq8YJ2ORYKWKEG0lLUCGkvGFzzDgsYdeWKGZB163+aujC
6IEwg5fMH950fW09LTaV+MZPDQgYGKgkRW8QfiLcknqJ4Ap46y2thusZE1euJtIk
zX0/FaBWQ9dGljdpG64RxU9e7KxCvBZs4Nr0C3ZUvqMTFPzMwLMdNte8ilF/5LD2
5TxTSsK3dHJsQFxz80p9I4IlreMw0ihg43ydN5cspKSMiyroF17xduBWsSbLLk61
VJ90VerJmbA=
=iBqK
-----END PGP SIGNATURE-----
--=-=-=--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Christopher Baines <mail@HIDDEN>
Subject: bug#68271: Acknowledgement ([PATCH 0/3] Make some deduplicating
 speedups.)
Message-ID: <handler.68271.B.170448785315419.ack <at> debbugs.gnu.org>
References: <87h6jrqzc7.fsf@HIDDEN>
X-Gnu-PR-Message: ack 68271
X-Gnu-PR-Package: guix-patches
X-Gnu-PR-Keywords: patch
Reply-To: 68271 <at> debbugs.gnu.org
Date: Fri, 05 Jan 2024 20:51:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 68271 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
68271: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D68271
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#68271] [PATCH 1/3] guix: utils: Add delete-duplicates/sort.
References: <87h6jrqzc7.fsf@HIDDEN>
In-Reply-To: <87h6jrqzc7.fsf@HIDDEN>
Resent-From: Christopher Baines <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Fri, 05 Jan 2024 20:54:01 +0000
Resent-Message-ID: <handler.68271.B68271.170448801115727 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 68271
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 68271 <at> debbugs.gnu.org
Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 68271-submit <at> debbugs.gnu.org id=B68271.170448801115727
          (code B ref 68271); Fri, 05 Jan 2024 20:54:01 +0000
Received: (at 68271) by debbugs.gnu.org; 5 Jan 2024 20:53:31 +0000
Received: from localhost ([127.0.0.1]:58036 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rLrC7-00045b-Ep
	for submit <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:53:31 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43068)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rLrC5-00045K-90
 for 68271 <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:53:30 -0500
Received: from localhost (unknown [217.155.61.229])
 by mira.cbaines.net (Postfix) with ESMTPSA id 94C4E27BBE2
 for <68271 <at> debbugs.gnu.org>; Fri,  5 Jan 2024 20:53:23 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 3df7c8f0
 for <68271 <at> debbugs.gnu.org>; Fri, 5 Jan 2024 20:53:22 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
Date: Fri,  5 Jan 2024 20:53:20 +0000
Message-ID: <ce0156e7528f6a6a54f0469774b41604e7872a22.1704488002.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Similar to delete-duplicates, but sorts the list first and then compares the
pairs in the list. This is faster than delete-duplicates for larger lists.

* guix/utils.scm (delete-duplicates): New procedure.

Change-Id: Ibc2897cdb7c76be0d0e099bc47fee005a88bea2e
---
 guix/utils.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/guix/utils.scm b/guix/utils.scm
index e4e9d922e7..c1c967ee6c 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -146,6 +146,8 @@ (define-module (guix utils)
             edit-expression
             delete-expression
 
+            delete-duplicates/sort
+
             filtered-port
             decompressed-port
             call-with-decompressed-port
@@ -502,6 +504,32 @@ (define (delete-expression source-properties)
   "Delete the expression specified by SOURCE-PROPERTIES."
   (edit-expression source-properties (const "") #:include-trailing-newline? #t))
 
+
+;;;
+;;; Lists.
+;;;
+
+(define* (delete-duplicates/sort unsorted-lst less #:optional (equal? eq?))
+  (if (null? unsorted-lst)
+      unsorted-lst
+      (let ((sorted-lst (sort unsorted-lst
+                              ;; Sort in the reverse order
+                              (lambda (a b) (eq? #f (less a b))))))
+        (let loop ((lst (cdr sorted-lst))
+                   (last-element (car sorted-lst))
+                   (result (list (car sorted-lst))))
+          (if (null? lst)
+              result
+              (let ((current-element (car lst)))
+                (if (equal? current-element last-element)
+                    (loop (cdr lst)
+                          last-element
+                          result)
+                    (loop (cdr lst)
+                          current-element
+                          (cons current-element
+                                result)))))))))
+
 
 ;;;
 ;;; Keyword arguments.

base-commit: deeb7d1f53d7ddfa977b3eadd760312bbd0a2509
-- 
2.41.0





Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#68271] [PATCH 2/3] guix: derivations: Use delete-duplicates/sort.
Resent-From: Christopher Baines <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Fri, 05 Jan 2024 20:54:02 +0000
Resent-Message-ID: <handler.68271.B68271.170448801215735 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 68271
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 68271 <at> debbugs.gnu.org
Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 68271-submit <at> debbugs.gnu.org id=B68271.170448801215735
          (code B ref 68271); Fri, 05 Jan 2024 20:54:02 +0000
Received: (at 68271) by debbugs.gnu.org; 5 Jan 2024 20:53:32 +0000
Received: from localhost ([127.0.0.1]:58038 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rLrC7-00045h-Py
	for submit <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:53:32 -0500
Received: from mira.cbaines.net ([212.71.252.8]:43070)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rLrC5-00045L-8w
 for 68271 <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:53:30 -0500
Received: from localhost (unknown [217.155.61.229])
 by mira.cbaines.net (Postfix) with ESMTPSA id E941127BBE9
 for <68271 <at> debbugs.gnu.org>; Fri,  5 Jan 2024 20:53:23 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 8acfac1b
 for <68271 <at> debbugs.gnu.org>; Fri, 5 Jan 2024 20:53:22 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
Date: Fri,  5 Jan 2024 20:53:21 +0000
Message-ID: <cb11dedad1ec9838e33af735b5176337334dc362.1704488002.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <ce0156e7528f6a6a54f0469774b41604e7872a22.1704488002.git.mail@HIDDEN>
References: <ce0156e7528f6a6a54f0469774b41604e7872a22.1704488002.git.mail@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

As this seems to be a small speedup, as tested by computing derivations for
all packages targeting i586-pc-gnu.

* guix/derivations.scm (derivation/masked-inputs): Use delete-duplicates/sort.

Change-Id: I9ec963c10e67a525037c346f44c92a87376935c5
---
 guix/derivations.scm | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/guix/derivations.scm b/guix/derivations.scm
index 9fec7f4f0b..29c7ef9a5c 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -745,10 +745,12 @@ (define (derivation/masked-inputs drv)
                              (make-derivation-input hash sub-drvs))))
                         inputs)))
        (make-derivation outputs
-                        (sort (delete-duplicates inputs)
-                              (lambda (drv1 drv2)
-                                (string<? (derivation-input-derivation drv1)
-                                          (derivation-input-derivation drv2))))
+                        (delete-duplicates/sort
+                         inputs
+                         (lambda (drv1 drv2)
+                           (string<? (derivation-input-derivation drv1)
+                                     (derivation-input-derivation drv2)))
+                         eq?)
                         sources
                         system builder args env-vars
                         #f)))))
-- 
2.41.0





Message sent to guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#68271] [PATCH 3/3] guix: packages: Speed up deduplicating inputs.
Resent-From: Christopher Baines <mail@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix@HIDDEN, dev@HIDDEN, ludo@HIDDEN, othacehe@HIDDEN, rekado@HIDDEN, zimon.toutoune@HIDDEN, me@HIDDEN, guix-patches@HIDDEN
Resent-Date: Fri, 05 Jan 2024 20:54:02 +0000
Resent-Message-ID: <handler.68271.B68271.170448803115766 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 68271
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: 68271 <at> debbugs.gnu.org
Cc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
X-Debbugs-Original-Xcc: Christopher Baines <guix@HIDDEN>, Josselin Poiret <dev@HIDDEN>, Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Ricardo Wurmus <rekado@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>
Received: via spool by 68271-submit <at> debbugs.gnu.org id=B68271.170448803115766
          (code B ref 68271); Fri, 05 Jan 2024 20:54:02 +0000
Received: (at 68271) by debbugs.gnu.org; 5 Jan 2024 20:53:51 +0000
Received: from localhost ([127.0.0.1]:58040 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rLrCC-00045z-5h
	for submit <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:53:51 -0500
Received: from mira.cbaines.net
 ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]:47199)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1rLrC7-00045N-B8
 for 68271 <at> debbugs.gnu.org; Fri, 05 Jan 2024 15:53:34 -0500
Received: from localhost (unknown [217.155.61.229])
 by mira.cbaines.net (Postfix) with ESMTPSA id 30C1B27BBEA
 for <68271 <at> debbugs.gnu.org>; Fri,  5 Jan 2024 20:53:24 +0000 (GMT)
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id 0c47e6c0
 for <68271 <at> debbugs.gnu.org>; Fri, 5 Jan 2024 20:53:23 +0000 (UTC)
From: Christopher Baines <mail@HIDDEN>
Date: Fri,  5 Jan 2024 20:53:22 +0000
Message-ID: <7bb6eeca77516fdd01e9b0b98eb9e21ac87c7509.1704488002.git.mail@HIDDEN>
X-Mailer: git-send-email 2.41.0
In-Reply-To: <ce0156e7528f6a6a54f0469774b41604e7872a22.1704488002.git.mail@HIDDEN>
References: <ce0156e7528f6a6a54f0469774b41604e7872a22.1704488002.git.mail@HIDDEN>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Use delete-duplicates/sort rather than delete-duplicates, as this seems to
perform a little better, at least when testing by computing derivations
targeting i586-pc-gnu for all packages.

* guix/packages.scm (input<?, deduplicate-inputs): New procedures.
(bag-derivation, bag->cross-derivation): Use deduplicate-inputs.

Change-Id: Ic47b50aa52f11d701e5aefa2a095219e3a98cfd1
---
 guix/packages.scm | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index 930b1a3b0e..09dc88e2af 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -1889,6 +1889,21 @@ (define (input=? input1 input2)
                       (derivation=? obj1 obj2))
                  (equal? obj1 obj2))))))))
 
+(define (input<? input1 input2)
+  (let ((label1 (first input1))
+        (label2 (first input2)))
+    (if (string=? label1 label2)
+        (let ((obj1 (second input1))
+              (obj2 (second input2)))
+          (if (and (derivation? obj1) (derivation? obj2))
+              (string<? (derivation-file-name obj1)
+                        (derivation-file-name obj2))
+              #f))
+        (string<? label1 label2))))
+
+(define-inlinable (deduplicate-inputs inputs)
+  (delete-duplicates/sort inputs input<? input=?))
+
 (define* (bag->derivation bag #:optional context)
   "Return the derivation to build BAG for SYSTEM.  Optionally, CONTEXT can be
 a package object describing the context in which the call occurs, for improved
@@ -1911,7 +1926,7 @@ (define* (bag->derivation bag #:optional context)
         ;; that lead to the same derivation.  Delete those duplicates to avoid
         ;; issues down the road, such as duplicate entries in '%build-inputs'.
         (apply (bag-build bag) (bag-name bag)
-               (delete-duplicates input-drvs input=?)
+               (deduplicate-inputs input-drvs)
                #:search-paths paths
                #:outputs (bag-outputs bag) #:system system
                (bag-arguments bag)))))
@@ -1951,9 +1966,9 @@ (define* (bag->cross-derivation bag #:optional context)
                                                  all))))
 
     (apply (bag-build bag) (bag-name bag)
-           #:build-inputs (delete-duplicates build-drvs input=?)
-           #:host-inputs (delete-duplicates host-drvs input=?)
-           #:target-inputs (delete-duplicates target-drvs input=?)
+           #:build-inputs (deduplicate-inputs build-drvs)
+           #:host-inputs (deduplicate-inputs host-drvs)
+           #:target-inputs (deduplicate-inputs target-drvs)
            #:search-paths paths
            #:native-search-paths npaths
            #:outputs (bag-outputs bag)
-- 
2.41.0





Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#68271] [PATCH 1/3] guix: utils: Add delete-duplicates/sort.
Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Fri, 12 Jan 2024 13:55:02 +0000
Resent-Message-ID: <handler.68271.B68271.170506764131745 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 68271
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: patch
To: Christopher Baines <mail@HIDDEN>
Cc: Josselin Poiret <dev@HIDDEN>, Simon Tournier <zimon.toutoune@HIDDEN>, Mathieu Othacehe <othacehe@HIDDEN>, Tobias Geerinckx-Rice <me@HIDDEN>, 68271 <at> debbugs.gnu.org, Ricardo Wurmus <rekado@HIDDEN>, Christopher Baines <guix@HIDDEN>
Received: via spool by 68271-submit <at> debbugs.gnu.org id=B68271.170506764131745
          (code B ref 68271); Fri, 12 Jan 2024 13:55:02 +0000
Received: (at 68271) by debbugs.gnu.org; 12 Jan 2024 13:54:01 +0000
Received: from localhost ([127.0.0.1]:35216 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rOHyz-0008Fq-A6
	for submit <at> debbugs.gnu.org; Fri, 12 Jan 2024 08:54:01 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:36810)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1rOHyx-0008Fc-2x
 for 68271 <at> debbugs.gnu.org; Fri, 12 Jan 2024 08:54:00 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1rOHyq-0001LQ-HZ; Fri, 12 Jan 2024 08:53:52 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To:
 From; bh=c4JbLNJ7In3P2B6B1lKm+fHIhkAAsb4pISt/ruXSRZw=; b=D37tEVyFiGqSXa3n1uT2
 2Y4HLdcsCFd03dkVdxHLdDsQkDyWqxZVau0vZgHgLXBzbGj5fuavxbjNlcBxJVhFtF1k7oezHRhyd
 WKY+OYB+GnNM/JhCinzB5CdlkKXievM1GS/iC97jKbntjoiXJcsKuVlyUk8Ap9d/nlvg7jAz4jsX1
 vN8Hx9gUC0k/7I2V/JDT+PYYyHLwIg0pjtfY7tXXNX4p/z0WKYBz/viBwGxNu0UH950C45zhgXWXR
 GtiNsjWoeBXxiuu4b4mAHFORrVznXNJ9xsTfGghrb7MAVU4I2p8KIjTuidJG9dnsTc59PP0quLpih
 eb/QBrvSF9DUyg==;
From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
In-Reply-To: <ce0156e7528f6a6a54f0469774b41604e7872a22.1704488002.git.mail@HIDDEN>
 (Christopher Baines's message of "Fri, 5 Jan 2024 20:53:20 +0000")
References: <87h6jrqzc7.fsf@HIDDEN>
 <ce0156e7528f6a6a54f0469774b41604e7872a22.1704488002.git.mail@HIDDEN>
Date: Fri, 12 Jan 2024 14:53:43 +0100
Message-ID: <87h6jik68o.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Christopher Baines <mail@HIDDEN> skribis:

> Similar to delete-duplicates, but sorts the list first and then compares =
the
> pairs in the list. This is faster than delete-duplicates for larger lists.

We=E2=80=99re dealing with small lists here though (derivation inputs).  Di=
d you
try to time the benefit?

There=E2=80=99s a complexity/benefit tradeoff and I wonder if it cuts it.

> +(define* (delete-duplicates/sort unsorted-lst less #:optional (equal? eq=
?))
> +  (if (null? unsorted-lst)
> +      unsorted-lst

This =E2=80=98if=E2=80=99 is unnecessary.

> +      (let ((sorted-lst (sort unsorted-lst
> +                              ;; Sort in the reverse order
> +                              (lambda (a b) (eq? #f (less a b))))))

Just: (negate less).

> +        (let loop ((lst (cdr sorted-lst))
> +                   (last-element (car sorted-lst))
> +                   (result (list (car sorted-lst))))
> +          (if (null? lst)
> +              result
> +              (let ((current-element (car lst)))

Please follow the convention of using =E2=80=98match=E2=80=99 rather than c=
ar caddr
caddddar (info "(guix) Data Types and Pattern Matching"):

  (match lst
    (()
     result)
    ((head . tail)
     =E2=80=A6))

Ludo=E2=80=99.





Last modified: Sat, 20 Jan 2024 12:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.