From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uN2aH4F3VWFIOwEAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 10:38:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id CCJgG4F3VWFbPgAA1q6Kng (envelope-from ) for ; Thu, 30 Sep 2021 08:38:25 +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 4EE5F1AC4D for ; Thu, 30 Sep 2021 10:38:24 +0200 (CEST) Received: from localhost ([::1]:56022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVraA-0001q4-B9 for larch@yhetil.org; Thu, 30 Sep 2021 04:38:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVrZq-0001oU-0d for guix-patches@gnu.org; Thu, 30 Sep 2021 04:38:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mVrZp-00052W-OY for guix-patches@gnu.org; Thu, 30 Sep 2021 04:38:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mVrZp-0006V1-IZ for guix-patches@gnu.org; Thu, 30 Sep 2021 04:38:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50755] [PATCH v3] import: Generate list of importers based on available modules Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Sep 2021 08:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50755 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: pinoaffe Cc: 50755@debbugs.gnu.org, zimoun Received: via spool by 50755-submit@debbugs.gnu.org id=B50755.163299105424948 (code B ref 50755); Thu, 30 Sep 2021 08:38:01 +0000 Received: (at 50755) by debbugs.gnu.org; 30 Sep 2021 08:37:34 +0000 Received: from localhost ([127.0.0.1]:51416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVrZN-0006UJ-TJ for submit@debbugs.gnu.org; Thu, 30 Sep 2021 04:37:34 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:38690) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mVrZJ-0006U7-7F for 50755@debbugs.gnu.org; Thu, 30 Sep 2021 04:37:32 -0400 Received: from ptr-bvsjgyjmffd7q9timvx.18120a2.ip6.access.telenet.be ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by baptiste.telenet-ops.be with bizsmtp id 08dN2600X0mfAB4018dNvA; Thu, 30 Sep 2021 10:37:26 +0200 Message-ID: From: Maxime Devos Date: Thu, 30 Sep 2021 10:37:17 +0200 In-Reply-To: <87r1d6zdcj.fsf@airmail.cc> References: <87tuibh43w.fsf@airmail.cc> <87mtnxswwq.fsf@airmail.cc> <4ddbb2adfa86c9ed2e1cf01ad5c1d0129553cbae.camel@telenet.be> <87k0j0hii3.fsf@airmail.cc> <87r1d6zdcj.fsf@airmail.cc> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-GxfpYhXalGHiWYrGFLkn" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1632991046; bh=mtRZfVuy52WLxQ1ybbVlHq4xIkduRoyEi6HwfY37Cgg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SZ19vf3VHvdlcdKTQCuQBDLSO81lTziCoYgGJ/J4Kgyf8rav2Ulz0+/Jb/GWshcVn 9FsNJqzy5zXs71O6cJix/wegKUXD7W0ovnt2GwCl34I8TSepiCGjpLYo3U9GpOXa4h lgs/iqETvozkWDdKcfmdI7yP1iNqLHhFKkMPN+r5Z+cbGjgzKo6CG6Hmi6M2HNqF10 mpIYm5lHZMtRq/Ulp2D/hk5Lrm9AqLavEkS7aOCGvOcFPfYApGxuIEa9DNS/bf0u/n eCqaIGEiH+tqouDcSSQ2mwKA3rGOqvnBHh8YqVWANBVlmBeNZXHyPAm7PPfRakhpeo MJF8bPL+r3rPg== 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632991105; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=mtRZfVuy52WLxQ1ybbVlHq4xIkduRoyEi6HwfY37Cgg=; b=NMqNFOFZvwcsukCn1BgSsPV0XfHlmdD+9XbE/kupZtjph82gQCW286RVggcGq7YD99A6fx fTqJ2X3526PeN3KwV0pTreGnDDKJQoVuARgHp57rqPGIa/c4TUOyZNOMxLfJHn1R1lfcFz Wul3lZNqLjUxQ5+Z4kMCqbKDOIbfHNTGFB4BpMwXPkXmIOb+3hFGESCpTr2ch1EZnmJmsA UkEhR2l/v2jx7a1+dRFkHtf53QrxVZc8jdB4e1OebdgEnNv2E1s+HlXW3HTcdV8cSpQYnw 4GOnsHlClKNLSQs5XavDWqj1q7Q0K04oW4JjeLrzmsctfaCpgpEPDV1SvvWnHg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632991105; a=rsa-sha256; cv=none; b=NcSfBzyqSPdg/MgT7EGIAUgotikPq2hFktgGkv9RWLlv8XkW04S8YzQvDzjGMith6nNE+T BECvCNVB2l6nCAcBWaDVScpKXPs20bs0Up1v38/IQOJaVlYoCJndqsc5ejtMreDiqx8QbV kWa37+aMpN4ryRxU29ENE0tL6qSaJ5XCvC+ffuQMtuhMYzlWwbAVylftaz/xyAOCOQ+l2W yqDQLS3SpxTOgPcqkIzghOYyWlnhJaR7zTjpsvqoNc4XdzyMA99etEjYjz3VitVt7JwvFm uDPP3bcTRLVoLRWJO115kb2QyAMYWqX+fvuIjcIQK2hjVauQBtIY0Bb+p97mSA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=SZ19vf3V; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=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-Migadu-Spam-Score: -3.40 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=SZ19vf3V; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=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-Migadu-Queue-Id: 4EE5F1AC4D X-Spam-Score: -3.40 X-Migadu-Scanner: scn0.migadu.com X-TUID: Me/blVYCcQLa --=-GxfpYhXalGHiWYrGFLkn Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable pinoaffe schreef op do 30-09-2021 om 10:17 [+0200]: > Maxime Devos writes: > > These numbers turn out to be misleading, because 'scheme-modules' > > (indirectly called from all-modules) calls 'resolve-interface' on every= module > > name. For a module name, the first 'resolve-module' incurs disk I/O an= d some > > CPU for loading the module, but the second 'resolve-module' on the same= module > > name would be free, as the module is already loaded. > okay, the first incantation of=20 >=20 > (time (for-each (lambda (_) > (delete-duplicates (filter-map (lambda (module) > (match (module-name module) > (`(guix scripts import ,importer) > (symbol->string importer)) > (#t #f))) > (all-modules (map (lambda (entry) > `(,entry . "guix/scripts/import")) > %load-path))))) > (iota 1))) >=20 > on a "fresh" guix repl on my system results in=20 >=20 > clock utime stime cutime cstime gctime > 1.28 0.76 0.13 0.00 0.00 0.16 On my fresh guix repl, it's a bit longer: clock utime stime cutime cstime gctime 9.54 1.79 0.31 0.00 0.00 0.53 (9 or 10 seconds) If I restart the guix repl and run it again, I get about half a second: clock utime stime cutime cstime gctime 0.47 0.57 0.02 0.00 0.00 0.19 > which is indeed a significant amount of time, though I don't think it'd > be much of an issue considering that it's not likely that users will run > lots of `guix import` shell commands in rapid succession. The list of importers is only needed for two purposes, right? 1. to print a list of importers when "guix import --help" is run 2. to verify the string actually specifies an importer Then 'guix import SOME-IMPORTER STUFF' could be optimised: reolve-importer and guix-import could be modified to skip the validation step and let resolve-importer print the error if the module couldn't be found. Possibly (resolve-module '(the possibly undefined module) #:ensure = #f) might be useful. Then 'importers' would only be required for purpose (1), so it could be wrapped in a promise, such that if "guix import some-importe= r stuff" is called, only the required importer module is loaded. Greetings, Maxime. --=-GxfpYhXalGHiWYrGFLkn Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYVV3PRccbWF4aW1lZGV2 b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7r2kAP9n4wQy7Hwm+gOfK7xoJ5hC5dTS R2nxUMr0HKz2lFlR4wEA+lMWrOz1DD7BQPmIIBASugkP1zH34bGBZQOuw/FS9gI= =bB49 -----END PGP SIGNATURE----- --=-GxfpYhXalGHiWYrGFLkn--