From: zimoun <zimon.toutoune@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 45893@debbugs.gnu.org
Subject: [bug#45893] Hint for package name: too slow!
Date: Wed, 20 Jan 2021 00:59:54 +0100 [thread overview]
Message-ID: <86o8hk8olh.fsf@gmail.com> (raw)
In-Reply-To: <87a6t4hlom.fsf_-_@gnu.org>
Hi Ludo,
> Next up is package names, right? :-)
As said I have tried to hint typo about packages for “guix show” 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
’find-packages-by-name’ and then if the returned list is empty, again
with ’fold-available-packages’ to find the closest name. Read the cache
only once implies a lot of work.
However, the first improvement is to speed up ’string-distance’. 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 “guix git log” (avoid to traverse all the history
tree before displaying but traverse when it is required, somehow).
Cheers,
simon
--8<---------------cut here---------------start------------->8---
scheme@(guix-user)>
(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
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=?
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 <current input>:31:9
0.00 0.15 0.00 <current input>:17:0:compute-distance
0.00 0.13 0.00 guix/discovery.scm:177:0:fold-module-public-variables
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---
next prev parent reply other threads:[~2021-01-20 0:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 16:37 [bug#45893] [PATCH 0/2] DRAFT: Hint for options zimoun
2021-01-15 16:39 ` [bug#45893] [PATCH 1/2] scripts: search, show: Replace 'args-fold*' by 'parse-command-line' zimoun
2021-01-15 16:39 ` [bug#45893] [PATCH 2/2] guix: scripts: Add hint for option typo zimoun
2021-01-19 17:20 ` [bug#45893] [PATCH 0/2] DRAFT: Hint for options Ludovic Courtès
2021-01-19 17:35 ` zimoun
2021-01-16 0:09 ` [bug#45893] [PATCH v2 0/3] DRAFT: Hint command line typo zimoun
2021-01-16 0:26 ` [bug#45893] [PATCH v2 1/3] scripts: search, show: Replace 'args-fold*' by 'parse-command-line' zimoun
2021-01-16 0:26 ` [bug#45893] [PATCH v2 2/3] guix: scripts: Add hint for option typo zimoun
2021-01-19 17:31 ` [bug#45893] [PATCH 0/2] DRAFT: Hint for options Ludovic Courtès
2021-01-16 0:26 ` [bug#45893] [PATCH v2 3/3] ui: Add command hint zimoun
2021-01-19 17:38 ` [bug#45893] [PATCH 0/2] DRAFT: Hint for options Ludovic Courtès
2021-01-19 18:01 ` zimoun
2021-01-26 20:53 ` Ludovic Courtès
2021-01-26 21:27 ` zimoun
2021-01-19 23:59 ` zimoun [this message]
2021-01-20 9:49 ` [bug#45893] Hint for package name: full matrix iteration zimoun
2021-01-26 21:00 ` [bug#45893] [PATCH 0/2] DRAFT: Hint for options Ludovic Courtès
2021-01-26 21:44 ` zimoun
2021-01-27 22:09 ` Ludovic Courtès
2021-01-19 21:28 ` [bug#45893] [PATCH v3 1/3] utils: Add string distance zimoun
2021-01-19 21:28 ` [bug#45893] [PATCH v3 2/3] guix: scripts: Add hint for option typo zimoun
2021-01-19 21:28 ` [bug#45893] [PATCH v3 3/3] ui: Add hint for command typo zimoun
2021-01-26 21:18 ` [bug#45893] [PATCH 0/2] DRAFT: Hint for options Ludovic Courtès
2021-01-26 21:20 ` Ludovic Courtès
2021-01-26 22:05 ` zimoun
2021-02-03 11:28 ` bug#45893: " Ludovic Courtès
2021-02-03 12:15 ` [bug#45893] " zimoun
[not found] ` <YBxQxSO57N4kV4N0@jasmine.lan>
[not found] ` <86tuqrbjxr.fsf@gmail.com>
2021-02-04 23:08 ` [bug#45893] Typo helper doesn't always know which command is missing zimoun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86o8hk8olh.fsf@gmail.com \
--to=zimon.toutoune@gmail.com \
--cc=45893@debbugs.gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).