From patchwork Wed May 14 20:23:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 42613 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 82DEE27BC4C; Wed, 14 May 2025 21:26:13 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D71C927BC49 for ; Wed, 14 May 2025 21:26:05 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFIft-0004C8-8i; Wed, 14 May 2025 16:25:57 -0400 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 ) id 1uFIf2-0001kK-Sx for guix-patches@gnu.org; Wed, 14 May 2025 16:25:12 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uFIf2-0006dx-Gb; Wed, 14 May 2025 16:25:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=BlNigzXycwlX5Nc/mdRj5/apnWXeAJRouV7Ps7v4kHo=; b=QiF8PU6Khc+/+/FErnuwLJFAgD2T1eWVOBOz8tY+4hGkrJk+aRBe2uI0IIlKeZTeg6KgYqOvjexNv1tBgy+SPvQ71JiB5p3IqLYStmtgAFw9ixd4WQgPvlgRHeTr0KXLMYVSf8WSy81nPBy2ee9Ljun10iDX7Y64145CREiR7nsQA9u7JibDG33tnRy5WCR/ekuD64gH4zE3Wcl8RL+lLOKYeaimMGscJoPJ7g/bEGeRh8oKCdAf4xq3tU21Nuj+7Q0nygO3KdYKjPWEz3PpCnl4Z8l9h6XV0ZF/fgmL8fl6LO18bgVIvdATzWox7OFhX3TDPEBCeaAY/KUpthpngQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uFIf0-0002Uy-14; Wed, 14 May 2025 16:25:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78432] [PATCH 1/2] channels: Speed up =?utf-8?b?4oCYY2hhbm5l?= =?utf-8?b?bC1uZXdzLWZvci1jb21taXTigJku?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Wed, 14 May 2025 20:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 78432 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78432@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Ian Eure , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.17472542549225 (code B ref -1); Wed, 14 May 2025 20:25:01 +0000 Received: (at submit) by debbugs.gnu.org; 14 May 2025 20:24:14 +0000 Received: from localhost ([127.0.0.1]:46096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uFIeD-0002Oc-9J for submit@debbugs.gnu.org; Wed, 14 May 2025 16:24:14 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56014) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uFIeA-0002NT-Ey for submit@debbugs.gnu.org; Wed, 14 May 2025 16:24:11 -0400 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 ) id 1uFIe4-00083L-Qy for guix-patches@gnu.org; Wed, 14 May 2025 16:24:05 -0400 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 ) id 1uFIe4-0006SO-5o; Wed, 14 May 2025 16:24:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=BlNigzXycwlX5Nc/mdRj5/apnWXeAJRouV7Ps7v4kHo=; b=X7HfFuYYISWerz daIli+pPKysijFtx0kzOJzKdsCwIqzsoD61FHg5ziGy9/Q9dXGkdC1+bqWs1N/eTLiZoKNAQciz+1 8Y+y+cP3csLZzlaCWLtoqi4RUmZqMAF4NTO9s+lA+hWQW13gJ7Wk5F+40wvfV9q00e8bIzBXBz5WY sGvcBYhJCHIu4K9I8n89B0cHZM1iNC2LrrtgMU2najbX7dLWn4YdyS5O7LCYGDe6PIYQ2yO0CZKs3 PbVhrhm5Rn95an/JyfW4nkcSq3ApJauyLay6pLA2yYjdqUj4NpsNkPbnu0L7VEKB/8IT4omBuSyLt sMIq1kYzLhXy6KqoZkrg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 14 May 2025 22:23:45 +0200 Message-ID: <9d07f070500e61169450678b48983454508636f8.1747254136.git.ludo@gnu.org> X-Mailer: git-send-email 2.49.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Partly fixes . This makes the wall-clock time of: guix pull --list-generations > /dev/null shrink from 33s to 4s on a profile with 8 generations. * guix/channels.scm (channel-news-for-commit): Rewrite in terms of ‘commit-descendant?’. Reported-by: Ian Eure Change-Id: I387e3dc37437e2d98bfd7ab710417f68d16146ad --- guix/channels.scm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) base-commit: c5265b90b055ee15908298c5d463301f1aae2eb1 diff --git a/guix/channels.scm b/guix/channels.scm index 7a02d24a84..f6b3f40cc3 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2018-2024 Ludovic Courtès +;;; Copyright © 2018-2025 Ludovic Courtès ;;; Copyright © 2018 Ricardo Wurmus ;;; Copyright © 2019 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Brice Waegeneire @@ -31,7 +31,7 @@ (define-module (guix channels) #:autoload (git structs) (git-error-code) #:autoload (guix git) (update-cached-checkout url+commit->name - commit-difference + commit-descendant? repository-info commit-short-id tag->commit @@ -48,7 +48,6 @@ (define-module (guix channels) #:use-module (guix progress) #:use-module (guix derivations) #:use-module (guix diagnostics) - #:use-module (guix sets) #:use-module (guix store) #:use-module (guix i18n) #:use-module (srfi srfi-1) @@ -1237,15 +1236,16 @@ (define* (channel-news-for-commit channel new #:optional old) entry)) (channel-news-entries news)))) (if old - (let* ((new (commit-lookup repository (string->oid new))) - (old (commit-lookup repository (string->oid old))) - (commits (list->set - (map (compose oid->string commit-id) - (commit-difference new old))))) - (filter (lambda (entry) - (set-contains? commits - (channel-news-entry-commit entry))) - entries)) + (let ((new (commit-lookup repository (string->oid new))) + (old (commit-lookup repository (string->oid old)))) + (take-while (lambda (entry) + (let ((entry (commit-lookup + repository + (string->oid + (channel-news-entry-commit entry))))) + (and (commit-descendant? new (list entry)) + (not (commit-descendant? old (list entry)))))) + entries)) entries))) '()))) (lambda (key error . rest) From patchwork Wed May 14 20:26:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 42614 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 60B0627BC4B; Wed, 14 May 2025 21:27:36 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id BDF8627BC49 for ; Wed, 14 May 2025 21:27:35 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uFIgz-0008HP-Qq; Wed, 14 May 2025 16:27:05 -0400 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 ) id 1uFIgx-0008F6-4a for guix-patches@gnu.org; Wed, 14 May 2025 16:27:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uFIgw-0007Av-1Y; Wed, 14 May 2025 16:27:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=zneLb/17FEaBMKi6Sm+RZAdKMErmSVOsl+cZYRHTj3I=; b=n04LU5uByAfttmTQViZCjJWBFk+1477koYe0XZAUIaX+yR7W3cWJuOKJzZiofCoxEeOWDgKJNwP9/3QZnzLkq/sSGtTcGPWhPVBxdWWv0D8dOQNj+RApBQVV9U1gQIxOYKWz/l3kV9j3FFOEhPx0DVYyQmK8otHWsY9lz0hT/a5HEA0ChwYXRUx1v7M7CNBcyjiJmrNJ1rfgfDvMaPuKrsX+O190SaGwhJbJCcYGbBRoi9DXIeoyeFaZI1h98xaksTMAOK69bn2LJqhOnjr+jy9WOqLEFnNHLmru5ePEaFJHZLgEb23Eij91jBvh0YS3iRcGke3Am0WNKnKyaFNO2w==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uFIgv-0002sa-NP; Wed, 14 May 2025 16:27:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#78432] [PATCH 2/2] git: Remove code for Guile-Git < 0.10.0. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Wed, 14 May 2025 20:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 78432 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 78432@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 78432-submit@debbugs.gnu.org id=B78432.174725441111018 (code B ref 78432); Wed, 14 May 2025 20:27:01 +0000 Received: (at 78432) by debbugs.gnu.org; 14 May 2025 20:26:51 +0000 Received: from localhost ([127.0.0.1]:46115 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uFIgj-0002rI-19 for submit@debbugs.gnu.org; Wed, 14 May 2025 16:26:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34234) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uFIgg-0002q4-Gx for 78432@debbugs.gnu.org; Wed, 14 May 2025 16:26:47 -0400 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 ) id 1uFIgb-000785-6a; Wed, 14 May 2025 16:26:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=zneLb/17FEaBMKi6Sm+RZAdKMErmSVOsl+cZYRHTj3I=; b=QBo3oaYVp9Ht1YLQ8967 3b0JcEFwclvC1ucl5ajIQh/xl0D5V1pxeqeWlL2PtpfnIXWLoMMLMN67IkKCw0yGdbGA6+2Lku4aW r/Zr7JPcfUnJkHMW7vY/8+PuWtrLh+6wYiqevvWOKpKvLjnrT0KyBdNBGMHn6fD7hr+m0OnD88Rbi CWDFTcRLKFEvIITU0gPWauodtQgj1k6eFT/zMca6LRSgUzKzLyXJsYlD+4aMyHKxsonVzJp0z1WAA +VEOwZpnKjkDi/0Pw7ASk2mT8OF75GMz0TpejAoQq7+JHKn8hvasoxpnKw22GLMyTpAvGJEAekPFe QeV84Hsmo1qsEA==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Wed, 14 May 2025 22:26:28 +0200 Message-ID: <9b5150861b2dfdea534d00df8d1351d9f3a8a59c.1747254136.git.ludo@gnu.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <9d07f070500e61169450678b48983454508636f8.1747254136.git.ludo@gnu.org> References: <9d07f070500e61169450678b48983454508636f8.1747254136.git.ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/git.scm (commit-relation, commit-descendant?): Remove code for Guile-Git < 0.10.0. (set-git-timeouts): Remove code for Guile-Git < 0.9.0. (report-git-error): Remove code for ancient Guile-Git. Change-Id: Ie597151ce4c1e5ea006e2783fcc510caed3f566c --- guix/git.scm | 90 ++++++++++++++-------------------------------------- 1 file changed, 24 insertions(+), 66 deletions(-) diff --git a/guix/git.scm b/guix/git.scm index 9975c9b92e..c1353c5c04 100644 --- a/guix/git.scm +++ b/guix/git.scm @@ -211,15 +211,9 @@ (define (set-git-timeouts connection-timeout read-timeout) when talking to remote Git servers. If one of them is #f, the corresponding default setting is kept unchanged." - ;; 'set-server-timeout!' & co. were added in Guile-Git 0.9.0. - (define (defined? variable) - (module-defined? (resolve-interface '(git)) variable)) - - (when (and (defined? 'set-server-connection-timeout!) - connection-timeout) + (when connection-timeout (set-server-connection-timeout! connection-timeout)) - (when (and (defined? 'set-server-timeout!) - read-timeout) + (when read-timeout (set-server-timeout! read-timeout))) (define* (clone* url directory #:key (verify-certificate? #t)) @@ -374,13 +368,7 @@ (define-syntax-rule (with-repository directory repository exp ...) (define (report-git-error error) "Report the given Guile-Git error." - ;; Prior to Guile-Git commit b6b2760c2fd6dfaa5c0fedb43eeaff06166b3134, - ;; errors would be represented by integers. - (match error - ((? integer? error) ;old Guile-Git - (leave (G_ "Git error ~a~%") error)) - ((? git-error? error) ;new Guile-Git - (leave (G_ "Git error: ~a~%") (git-error-message error))))) + (leave (G_ "Git error: ~a~%") (git-error-message error))) (define-syntax-rule (with-git-error-handling body ...) (catch 'git-error @@ -769,60 +757,30 @@ (define* (commit-difference new old #:optional (excluded '())) (cons head result) (set-insert head visited))))))) -(define commit-relation - (if (resolve-module '(git graph) #:ensure #f) ;Guile-Git >= 0.10.0 - (lambda (old new) - "Return a symbol denoting the relation between OLD and NEW, two commit +(define (commit-relation old new) + "Return a symbol denoting the relation between OLD and NEW, two commit objects: 'ancestor (meaning that OLD is an ancestor of NEW), 'descendant, or 'unrelated, or 'self (OLD and NEW are the same commit)." - (let ((repository (commit-owner old)) - (old (commit-id old)) - (new (commit-id new))) - (cond ((graph-descendant? repository new old) - 'ancestor) - ((oid=? old new) - 'self) - ((graph-descendant? repository old new) - 'descendant) - (else 'unrelated)))) - (lambda (old new) ;remove when Guile-Git 0.10.0 is widespread - (if (eq? old new) - 'self - (let ((newest (commit-closure new))) - (if (set-contains? newest old) - 'ancestor - (let* ((seen (list->setq (commit-parents new))) - (oldest (commit-closure old seen))) - (if (set-contains? oldest new) - 'descendant - 'unrelated)))))))) + (let ((repository (commit-owner old)) + (old (commit-id old)) + (new (commit-id new))) + (cond ((graph-descendant? repository new old) + 'ancestor) + ((oid=? old new) + 'self) + ((graph-descendant? repository old new) + 'descendant) + (else 'unrelated)))) -(define commit-descendant? - (if (resolve-module '(git graph) #:ensure #f) ;Guile-Git >= 0.10.0 - (lambda (new old) - "Return true if NEW is the descendant of one of OLD, a list of -commits." - (let ((repository (commit-owner new)) - (new (commit-id new))) - (any (lambda (old) - (let ((old (commit-id old))) - (or (graph-descendant? repository new old) - (oid=? old new)))) - old))) - (lambda (new old) ;remove when Guile-Git 0.10.0 is widespread - (let ((old (list->setq old))) - (let loop ((commits (list new)) - (visited (setq))) - (match commits - (() - #f) - (_ - ;; Perform a breadth-first search as this is likely going to - ;; terminate more quickly than a depth-first search. - (let ((commits (remove (cut set-contains? visited <>) commits))) - (or (any (cut set-contains? old <>) commits) - (loop (append-map commit-parents commits) - (fold set-insert visited commits))))))))))) +(define (commit-descendant? new old) + "Return true if NEW is the descendant of one of OLD, a list of commits." + (let ((repository (commit-owner new)) + (new (commit-id new))) + (any (lambda (old) + (let ((old (commit-id old))) + (or (graph-descendant? repository new old) + (oid=? old new)))) + old))) ;;