From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id uDk5EftzB2DxDgAA0tVLHw (envelope-from ) for ; Wed, 20 Jan 2021 00:06:19 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id mGUTDftzB2AZOAAAB5/wlQ (envelope-from ) for ; Wed, 20 Jan 2021 00:06:19 +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 A09D49402C8 for ; Wed, 20 Jan 2021 00:06:18 +0000 (UTC) Received: from localhost ([::1]:35376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l210r-0000D8-L6 for larch@yhetil.org; Tue, 19 Jan 2021 19:06:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l210d-0000Cr-A0 for guix-patches@gnu.org; Tue, 19 Jan 2021 19:06:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:40601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l210c-0001gu-Ae for guix-patches@gnu.org; Tue, 19 Jan 2021 19:06:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l210c-0005eJ-4i for guix-patches@gnu.org; Tue, 19 Jan 2021 19:06:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45893] Hint for package name: too slow! Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 20 Jan 2021 00:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45893 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 45893-submit@debbugs.gnu.org id=B45893.161110115221699 (code B ref 45893); Wed, 20 Jan 2021 00:06:02 +0000 Received: (at 45893) by debbugs.gnu.org; 20 Jan 2021 00:05:52 +0000 Received: from localhost ([127.0.0.1]:52147 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l210S-0005dv-60 for submit@debbugs.gnu.org; Tue, 19 Jan 2021 19:05:52 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:35787) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l210M-0005de-SR for 45893@debbugs.gnu.org; Tue, 19 Jan 2021 19:05:50 -0500 Received: by mail-wm1-f49.google.com with SMTP id e15so1306205wme.0 for <45893@debbugs.gnu.org>; Tue, 19 Jan 2021 16:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=T1YGZd1jiB1/keX2Fr/77gsDVsoLQrjfq1ToSNegR3Y=; b=NFiCIZO46jpG4M1ZkUbahe5UAygHYmu2bRRGgPMX4qvinKnoJYdXqgvm7SyUTfUdb4 vINkxEZdYWVjq5JkLznoVFCFhV2g9t/ngGV864WFc2+iS7P+GSUGoTT1fpwMiFv6zYW5 cOoBQCYhK5QmZ+mGusPgXdTUwtT8hNinA5Ggr+lo4TsYe24Vu35Ym2dU/ySsULBykIF7 8XyfMLdC0nBpbPJ9MTfz1Hz2E6oKB/B6YmMUeh+976W6Lgtm82N1PVD8eTnDdxQxD06u fCWSqAissq7nd0rTrXSlVeJF2f5IF6d4TkVVHUykLxgE9uUGrbLqE8OBP8Xa6mm+fpTo t95A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=T1YGZd1jiB1/keX2Fr/77gsDVsoLQrjfq1ToSNegR3Y=; b=EdRuOF0cfs3NKtrobsIXy2TKG45qWSY8uJcAlxWHY7j1AZFvMOVn85a4pr6Y1crwZE CD84cdrmqrvroSariNvI+CbUmpfWYJEyWgxEDIAKsV6ejnBI+qzrTrAaI52kf34HqEyS XR4H5wu4zKO8SN6IGc4U2Py6NLbtSxIBKH6T8Is0UyJSX0kggpCuft0N7sa6lnEDpode dEc5WdKJV/lXl8kyztkYEVRnwMlyIvktc61QVhGVJkUC2jSImH0W2WkrCw/MhcDPkVVj /UxGghIR6+nujceTWN75sqx8hwv8uZpAqpMqUIo2AetPtGUqsFZG2hVaTqvD9NPG+u/Q XCeA== X-Gm-Message-State: AOAM532Ao2eDe/VGU1mkPesbI310HRq98rfVc16MMGcMkRkACIFteKLG brIhSB5zSKM+TySNMZ67cNKZSKy+sjQ= X-Google-Smtp-Source: ABdhPJw5rsleBSPpK6cF5tbts3OTjvbds1DAVW0HjVqRlduELOhCER5oCP6qJhk+P2l0EZqR8SiMOA== X-Received: by 2002:a7b:cc0a:: with SMTP id f10mr1718664wmh.6.1611101140715; Tue, 19 Jan 2021 16:05:40 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id q7sm520557wrx.18.2021.01.19.16.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Jan 2021 16:05:40 -0800 (PST) From: zimoun In-Reply-To: <87a6t4hlom.fsf_-_@gnu.org> References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> <20210116002634.10401-3-zimon.toutoune@gmail.com> <87a6t4hlom.fsf_-_@gnu.org> Date: Wed, 20 Jan 2021 00:59:54 +0100 Message-ID: <86o8hk8olh.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: , Cc: 45893@debbugs.gnu.org Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=NFiCIZO4; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (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: A09D49402C8 X-Spam-Score: -1.25 X-Migadu-Scanner: scn0.migadu.com X-TUID: QPVHsE4PA2P0 Hi Ludo, > Next up is package names, right? :-) As said I have tried to hint typo about packages for =E2=80=9Cguix show=E2= =80=9D but it is too slow. So, in procrastinating mood, I have tried to investigate a bit. Currently, the cache would be read 2 times, once by =E2=80=99find-packages-by-name=E2=80=99 and then if the returned list is em= pty, again with =E2=80=99fold-available-packages=E2=80=99 to find the closest name. R= ead the cache only once implies a lot of work. However, the first improvement is to speed up =E2=80=99string-distance=E2= =80=99. Well, the naive recursive implementation is well-known to be really slow. Well, one question is: what is the status of Stream in Guile? Without drifting the initial topic, I am interested by the answer because it could be useful for =E2=80=9Cguix git log=E2=80=9D (avoid to traverse all t= he history tree before displaying but traverse when it is required, somehow). Cheers, simon --8<---------------cut here---------------start------------->8--- scheme@(guix-user)>=20 (use-modules (gnu packages) (guix utils)) (define (read-the-cache guess) (map (lambda (name) (identity name)) (fold-available-packages (lambda* (name version result #:key supported? deprecated? #:allow-other-keys) (if (and supported? (not deprecated?)) (cons name result) result)) '()))) (define (compute-distance guess) (map (lambda (name) (string-distance guess name)) (fold-available-packages (lambda* (name version result #:key supported? deprecated? #:allow-other-keys) (if (and supported? (not deprecated?)) (cons name result) result)) '()))) scheme@(guix-user)> ,time (define foo (read-the-cache "macs-mgit")) ;; 3.492591s real time, 4.523108s run time. 1.530055s spent in GC. scheme@(guix-user)> ,time (define foo (read-the-cache "macs-mgit")) ;; 0.125346s real time, 0.123948s run time. 0.000000s spent in GC. scheme@(guix-user)> ,time (define foo (compute-distance "macs-mgit")) ;; 3.813699s real time, 6.051472s run time. 3.256658s spent in GC. scheme@(guix-user)> ,profile (define foo (compute-distance "macs-mgit")) % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 time seconds seconds procedure 44.68 51.86 1.83 guix/memoization.scm:100:0 17.55 0.72 0.72 hash-set! 12.23 0.54 0.50 guix/utils.scm:863:2:mproc 9.04 0.37 0.37 hash-ref 4.26 47.60 0.17 guix/utils.scm:863:2 3.19 0.13 0.13 list? 2.13 0.09 0.09 string->list 1.60 0.07 0.07 min 1.06 0.04 0.04 ice-9/popen.scm:183:0:reap-pipes 1.06 0.04 0.04 length 0.53 0.26 0.02 guix/combinators.scm:37:2:fold2 0.53 0.02 0.02 equal? 0.53 0.02 0.02 gnu/packages.scm:246:32 0.53 0.02 0.02 char=3D? 0.53 0.02 0.02 pointer->string 0.53 0.02 0.02 srfi/srfi-1.scm:951:15 0.00 30583.00 0.00 ice-9/boot-9.scm:220:5:map1 0.00 4.08 0.00 :31:9 0.00 0.15 0.00 :17:0:compute-distance 0.00 0.13 0.00 guix/discovery.scm:177:0:fold-module-public-var= iables 0.00 0.11 0.00 guix/discovery.scm:184:19 0.00 0.09 0.00 gnu/packages.scm:224:21 0.00 0.09 0.00 guix/utils.scm:860:0:string-distance 0.00 0.04 0.00 guix/packages.scm:933:0:supported-package? 0.00 0.04 0.00 srfi/srfi-1.scm:734:0:find-tail 0.00 0.04 0.00 %after-gc-thunk 0.00 0.04 0.00 anon #x227d190 0.00 0.02 0.00 ice-9/boot-9.scm:1673:4:with-exception-handler 0.00 0.02 0.00 guix/discovery.scm:43:0:scheme-files 0.00 0.02 0.00 gnu/packages.scm:237:0:fold-packages 0.00 0.02 0.00 srfi/srfi-1.scm:452:2:fold 0.00 0.02 0.00 guix/discovery.scm:137:8 0.00 0.02 0.00 guix/build/syscalls.scm:993:4 0.00 0.02 0.00 guix/discovery.scm:59:14 0.00 0.02 0.00 guix/discovery.scm:100:0:scheme-modules 0.00 0.02 0.00 guix/discovery.scm:148:0:all-modules 0.00 0.02 0.00 guix/build/syscalls.scm:1014:0:scandir* 0.00 0.02 0.00 srfi/srfi-1.scm:487:0:fold-right --- Sample count: 188 Total time: 4.084680487 seconds (2.659723098 seconds in GC) scheme@(guix-user)> --8<---------------cut here---------------end--------------->8---