From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sN0VJSrXsl80DwAA0tVLHw (envelope-from ) for ; Mon, 16 Nov 2020 19:46:50 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id uErrICrXsl+TSAAA1q6Kng (envelope-from ) for ; Mon, 16 Nov 2020 19:46:50 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3603294011C for ; Mon, 16 Nov 2020 19:46:50 +0000 (UTC) Received: from localhost ([::1]:60876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekSf-0005eG-5F for larch@yhetil.org; Mon, 16 Nov 2020 14:46:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kejrD-0001xY-HL for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:07 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kejrA-0001FL-Av for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kejrA-0002st-6U for guix-patches@gnu.org; Mon, 16 Nov 2020 14:08:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#38408] [PATCH v17 4/8] import: crate: Memorize crate->guix-package. Resent-From: Hartmut Goebel Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 16 Nov 2020 19:08:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38408 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38408@debbugs.gnu.org Cc: Martin Becze Received: via spool by 38408-submit@debbugs.gnu.org id=B38408.160555367010969 (code B ref 38408); Mon, 16 Nov 2020 19:08:04 +0000 Received: (at 38408) by debbugs.gnu.org; 16 Nov 2020 19:07:50 +0000 Received: from localhost ([127.0.0.1]:57250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqw-0002qm-5m for submit@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:50 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:41996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kejqr-0002qS-VG for 38408@debbugs.gnu.org; Mon, 16 Nov 2020 14:07:46 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CZdr13qxhz1rwDW; Mon, 16 Nov 2020 20:07:45 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CZdr13Yn7z1qqkD; Mon, 16 Nov 2020 20:07:45 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id WlBhByZuV2Kr; Mon, 16 Nov 2020 20:07:43 +0100 (CET) Received: from hermia.goebel-consult.de (ppp-188-174-59-253.dynamic.mnet-online.de [188.174.59.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Mon, 16 Nov 2020 20:07:43 +0100 (CET) Received: from thisbe.fritz.box (thisbe.fritz.box [192.168.110.24]) by hermia.goebel-consult.de (Postfix) with ESMTP id 4A98D604C7; Mon, 16 Nov 2020 20:08:28 +0100 (CET) From: Hartmut Goebel Date: Mon, 16 Nov 2020 20:07:24 +0100 Message-Id: <31b17421ebdbd8b2e8037b1163a7c90835dea7e6.1605552418.git.h.goebel@crazy-compilers.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.7 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: 3.99 X-TUID: FkT9lD8UmYKu From: Martin Becze This adds memorization to procedures that involve network lookups. 'lookup-crate*' is used on every dependency of a package to get its version list. It is also used to lookup a package's metadata. 'crate-recursive-import' is also memorized since creating the same package twice will trigger a lookup on its dependencies. * guix/import/crate.scm (lookup-crate*): New procedure. (crate->guix-package): Memorize package metadata lookups. (crate-recursive-import): Memorize package creation. --- guix/import/crate.scm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/guix/import/crate.scm b/guix/import/crate.scm index 5498d1f0ff..c830449555 100644 --- a/guix/import/crate.scm +++ b/guix/import/crate.scm @@ -27,6 +27,7 @@ #:use-module (guix import json) #:use-module (guix import utils) #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix memoization) #:use-module (guix monads) #:use-module (guix packages) #:use-module (guix upstream) @@ -110,6 +111,8 @@ record or #f if it was not found." (json->crate `(,@alist ("actual_versions" . ,versions)))))))) +(define lookup-crate* (memoize lookup-crate)) + (define (crate-version-dependencies version) "Return the list of records of VERSION, a ." @@ -215,7 +218,7 @@ version of CRATE-NAME." (eq? (crate-dependency-kind dependency) 'normal))) (define crate - (lookup-crate crate-name)) + (lookup-crate* crate-name)) (define version-number (and crate @@ -247,7 +250,7 @@ version of CRATE-NAME." (define (sort-map-dependencies deps) (sort (map (lambda (dep) (let* ((name (crate-dependency-id dep)) - (crate (lookup-crate name)) + (crate (lookup-crate* name)) (req (crate-dependency-requirement dep)) (ver (find-crate-version crate req))) (list name @@ -276,7 +279,7 @@ version of CRATE-NAME." (define* (crate-recursive-import crate-name #:key version) (recursive-import crate-name - #:repo->guix-package crate->guix-package + #:repo->guix-package (memoize crate->guix-package) #:version version #:guix-name crate-name->package-name)) -- 2.21.3