From 6d6d897b5454e9fad50e373e8051cbe1c81e495a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 14 May 2025 22:05:02 +0200 Subject: [PATCH] =?UTF-8?q?channels:=20Speed=20up=20=E2=80=98channel-news-?= =?UTF-8?q?for-commit=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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(-) diff --git a/guix/channels.scm b/guix/channels.scm index 7a02d24a846a84b85a3b6a43c25789ccdd5c24db..f6b3f40cc35cc9692511fa61a3ccc359b9296948 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 @@ #: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 @@ #: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 @@ NEW. When OLD is omitted or is #f, return all the news entries of CHANNEL." 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)