From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: scratch/backend-completion aaaa016056 2/2: Speed it up Date: Sun, 4 Dec 2022 11:11:42 +0000 Message-ID: References: <167007345844.23701.8454474119701440468@vcs2.savannah.gnu.org> <20221203131739.3FCF9C004BE@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000006be9f005eefea3db" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14836"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 04 12:12:48 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1mvP-0003cX-O1 for ged-emacs-devel@m.gmane-mx.org; Sun, 04 Dec 2022 12:12:47 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1mue-0001CH-Mk; Sun, 04 Dec 2022 06:12:00 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1muc-0001C3-70 for emacs-devel@gnu.org; Sun, 04 Dec 2022 06:11:58 -0500 Original-Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1muZ-0008IZ-Ny for emacs-devel@gnu.org; Sun, 04 Dec 2022 06:11:57 -0500 Original-Received: by mail-oi1-x22f.google.com with SMTP id v70so1670222oie.3 for ; Sun, 04 Dec 2022 03:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aUInvrJew9BXUNoptAjc1zik0fgTUsDolBE6CbwDY/c=; b=kUpgH6IAdkZt8ysYUfvbrWYWQHOkIw01WJEnOBr0Q+ioklAyeDzq18lZSRRfgPJmhV EP4InpPm1pAWsVVHFbMv3oeiBIwzk35Nc2W7nfFPmFhSV26nqmkrERn/NqCC03/Vnrlm 9Us2gZ7J7NN6BdSkuHJvdx06qftPUf322toyKxN5Suvm+ON2Q/8aOvSwb1Bx7IQkqTIa jCRPYqiaVKoqpbgW9ltzwSrQZfGcQuu+OjUgwKQ53rLQ5HrZfl2oMrQlsoQDKL57OrEp c7TmtFqqRaJeuffyJNrgN4TNRkO0iXejOJoRlEeoWTuFgKLgKKPR9OZj5OUI7Lp31gSi h0Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aUInvrJew9BXUNoptAjc1zik0fgTUsDolBE6CbwDY/c=; b=hE7c8DB5knJj0T6xw7RmvZl1SWSJpiaWrN9bJCFVE3gq2u8Xi+UP/dXmYhpArcfrfS 7EO3LDArQUHxAH9xBgA544ZCZeL3KJj84q0yv3XcDtx6obdq9BGqECq4j7Ip0rRy0M0c I2n6fKuiopUHh15v9EreHPhdBBqRxVNB+Yst6kv9n11ywFz6vFuCLvxQw7PZMUGr/sf9 5GcmEt8zQGvE6B3kCgZQNNLvCeLe9qHpMNbzW2HGcRLwRL4rh08Bz4/axhe8P7fP4xWx /EIScY87FRfwnSG56bPHOyr5lzFPk/LrZtJhjpQ6ZClTmIpaIn+jvg59W4u1Fgf20wgL UxpA== X-Gm-Message-State: ANoB5plgWzskRPz1jZBROCv4v1OMopEPuhbAutxM8/qscYnDI6QuCy2i JkdSn8djNoz7wPWp6iSk8glkuIBmdix2O8q046RMXzRNUYw= X-Google-Smtp-Source: AA0mqf6U/BdC988zl+ElcS1jQg7ahwpERzUOF1x9lf4Yt1BUdTHvvxwk/tKTx8jQuBKEk/jepn4crO0h7ITJrqGnZmc= X-Received: by 2002:aca:ac44:0:b0:35c:2ddf:59d5 with SMTP id v65-20020acaac44000000b0035c2ddf59d5mr594538oie.215.1670152314414; Sun, 04 Dec 2022 03:11:54 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=joaotavora@gmail.com; helo=mail-oi1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300902 Archived-At: --0000000000006be9f005eefea3db Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Dec 4, 2022 at 12:18 AM Stefan Monnier wrote: > > >> But I'm surprised it made things slow: this code should only be involved > >> when the user choose some *other* completion style, so could you check > >> which method of the completion table was invoked? > > It seems to be called with both `nil` and `lambda`. I've added this to the > > FIXME comment. > > Hmm... can you get a backtrace for when it's called with `nil`? See after my sig: > > It made things slow because when selecting a candidate with > > fido-vertical-mode it did another useless 0.5s/1s lookup for the thing > > I had just selected. > > Yes, it's only meant as a fallback case (and if we intend it to work > more or less acceptably we'd need to add some caching). Been there, done that :-) > >> Maybe we should only use that code when `action` is one of `t` or `nil`? > > Maybe. Anyway in my tests it's working fine without it. But `nil` doesn't > > break them, so I'm fine if you add them. I'm just confused about the > > possible benefits that may come from that complexity. I wish you could > > post an illustrative example with some strings that a mere mortal might > > follow along. > > As I said, it's for the case where the users want to use that completion > table with another completion-style. See the comment block. I think we should just error if the user tries to do that. Jo=C3=A3o Here's the backtrace you ordered, sir: Debugger entered: nil #f(compiled-function (--cl-lookup-internal-- string pred action method) #)(#f(compiled-function (string point) #) "doc/misc/eglot.texi" nil nil nil) #f(compiled-function (string pred action) #)("doc/misc/eglot.texi" nil nil) try-completion("doc/misc/eglot.texi" #f(compiled-function (string pred action) #) nil) completion--complete-and-exit(41 60 exit-minibuffer #f(compiled-function () #)) minibuffer-force-complete-and-exit() icomplete-force-complete-and-exit() icomplete-fido-ret() funcall-interactively(icomplete-fido-ret) call-interactively(icomplete-fido-ret nil nil) command-execute(icomplete-fido-ret) read-from-minibuffer("Eel find file in ~/Source/Emacs/emacs/: " nil (keymap (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (M-down . minibuffer-next-completion) (M-up . minibuffer-previous-completion) (27 keymap (13 . minibuffer-choose-completion) (103 keymap (27 keymap (99 . switch-to-completions))) (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (backtab . minibuffer-complete) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the min...") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuf...") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "\15" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (24 keymap (down . minibuffer-complete-defaults) (up . minibuffer-complete-history)) (13 . exit-minibuffer) (10 . exit-minibuffer) (7 . minibuffer-keyboard-quit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-line-or-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-line-or-history-element) (next . next-history-element) (27 keymap (60 . minibuffer-beginning-of-buffer) (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))) nil nil nil nil) completing-read-default("Eel find file in ~/Source/Emacs/emacs/: " #f(compiled-function (string pred action) #) nil nil nil nil nil nil) completing-read("Eel find file in ~/Source/Emacs/emacs/: " #f(compiled-function (string pred action) #) nil nil nil nil) eel-find-file("~/Source/Emacs/emacs/") funcall-interactively(eel-find-file "~/Source/Emacs/emacs/") call-interactively(eel-find-file nil nil) command-execute(eel-find-file) --0000000000006be9f005eefea3db Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Dec 4, 2022 at 12:18 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote= :
>
> >> But I'm surprised it made things slow: this = code should only be involved
> >> when the user choose some *ot= her* completion style, so could you check
> >> which method of = the completion table was invoked?
> > It seems to be called with b= oth `nil` and `lambda`. I've added this to the
> > FIXME comme= nt.
>
> Hmm... can you get a backtrace for when it's called= with `nil`?

See after my sig:

> > I= t made things slow because when selecting a candidate with
> > fid= o-vertical-mode it did another useless 0.5s/1s lookup for the thing
>= > I had just selected.
>
> Yes, it's only meant as a fa= llback case (and if we intend it to work
> more or less acceptably we= 'd need to add some caching).

Been there, done= that :-)

> >> Maybe we should only use t= hat code when `action` is one of `t` or `nil`?
> > Mayb= e.=C2=A0 Anyway in my tests it's working fine without it.=C2=A0 But `ni= l` doesn't
> > break them, so I'm fine if you add them.=C2= =A0 I'm just confused about the
> > possible benefits that may= come from that complexity.=C2=A0 I wish you could
> > post an ill= ustrative example with some strings that a mere mortal might
> > f= ollow along.
>
> As I said, it's for the case where the use= rs want to use that completion
> table with another completion-style.=

See the comment block.=C2=A0 I think we should just error if the us= er tries=C2=A0
to do that.

Jo=C3=A3o
=

Here's the backtrace you ordered, sir:
<= div>
Debugger entered: nil
=C2=A0 #f(compiled-function (--= cl-lookup-internal-- string pred action method) #<bytecode -0x1dfbb45767= c3fc90>)(#f(compiled-function (string point) #<bytecode -0x1a49dbcf59= 322b1d>) "doc/misc/eglot.texi" nil nil nil)
=C2=A0 #f(compi= led-function (string pred action) #<bytecode -0x6cbef0a719c4d65>)(&qu= ot;doc/misc/eglot.texi" nil nil)
=C2=A0 try-completion("doc/mi= sc/eglot.texi" #f(compiled-function (string pred action) #<bytecode= -0x6cbef0a719c4d65>) nil)
=C2=A0 completion--complete-and-exit(41 60= exit-minibuffer #f(compiled-function () #<bytecode -0x18333a20a7fa497&g= t;))
=C2=A0 minibuffer-force-complete-and-exit()
=C2=A0 icomplete-for= ce-complete-and-exit()
=C2=A0 icomplete-fido-ret()
=C2=A0 funcall-int= eractively(icomplete-fido-ret)
=C2=A0 call-interactively(icomplete-fido-= ret nil nil)
=C2=A0 command-execute(icomplete-fido-ret)
=C2=A0 read-f= rom-minibuffer("Eel find file in ~/Source/Emacs/emacs/: " nil (ke= ymap (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item &q= uot;Complete" minibuffer-complete :help "Complete as far as possi= ble") (space menu-item "Complete Word" minibuffer-complete-w= ord :help "Complete at most one word") (63 menu-item "List C= ompletions" minibuffer-completion-help :help "Display all possibl= e completions") "Minibuf")) (M-down . minibuffer-next-comple= tion) (M-up . minibuffer-previous-completion) (27 keymap (13 . minibuffer-c= hoose-completion) (103 keymap (27 keymap (99 . switch-to-completions))) (11= 8 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffe= r-completion-help) (32 . minibuffer-complete-word) (backtab . minibuffer-co= mplete) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Mi= nibuf" keymap (previous menu-item "Previous History Item" pr= evious-history-element :help "Put previous minibuffer history element = in the min...") (next menu-item "Next History Item" next-his= tory-element :help "Put next minibuffer history element in the minibuf= ...") (isearch-backward menu-item "Isearch History Backward"= isearch-backward :help "Incrementally search minibuffer history backw= ard") (isearch-forward menu-item "Isearch History Forward" i= search-forward :help "Incrementally search minibuffer history forward&= quot;) (return menu-item "Enter" exit-minibuffer :key-sequence &q= uot;\15" :help "Terminate input and exit minibuffer") (quit = menu-item "Quit" abort-recursive-edit :help "Abort input and= exit minibuffer") "Minibuf")) (24 keymap (down . minibuffer= -complete-defaults) (up . minibuffer-complete-history)) (13 . exit-minibuff= er) (10 . exit-minibuffer) (7 . minibuffer-keyboard-quit) (C-tab . file-cac= he-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-hist= ory-element) (up . previous-line-or-history-element) (prior . previous-hist= ory-element) (XF86Forward . next-history-element) (down . next-line-or-hist= ory-element) (next . next-history-element) (27 keymap (60 . minibuffer-begi= nning-of-buffer) (114 . previous-matching-history-element) (115 . next-matc= hing-history-element) (112 . previous-history-element) (110 . next-history-= element))) nil nil nil nil)
=C2=A0 completing-read-default("Eel fin= d file in ~/Source/Emacs/emacs/: " #f(compiled-function (string pred a= ction) #<bytecode -0x6cbef0a719c4d65>) nil nil nil nil nil nil)
= =C2=A0 completing-read("Eel find file in ~/Source/Emacs/emacs/: "= #f(compiled-function (string pred action) #<bytecode -0x6cbef0a719c4d65= >) nil nil nil nil)
=C2=A0 eel-find-file("~/Source/Emacs/emacs/&= quot;)
=C2=A0 funcall-interactively(eel-find-file "~/Source/Emacs/e= macs/")
=C2=A0 call-interactively(eel-find-file nil nil)
=C2=A0 = command-execute(eel-find-file)


--0000000000006be9f005eefea3db--