From patchwork Mon Nov 16 19:07:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hartmut Goebel X-Patchwork-Id: 25167 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 8A43E27BBF6; Mon, 16 Nov 2020 19:46:49 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 20E0127BBF5 for ; Mon, 16 Nov 2020 19:46:49 +0000 (GMT) Received: from localhost ([::1]:60876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kekSe-0005eG-Ag for patchwork@mira.cbaines.net; Mon, 16 Nov 2020 14:46:48 -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 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" X-getmail-retrieved-from-mailbox: Patches 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))