From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#48841: fido-mode is slower than ido-mode with similar settings Date: Sun, 13 Jun 2021 15:29:33 +0100 Message-ID: <87zgvtu9bm.fsf@gmail.com> References: <87eedgy7pt.fsf@gmail.com> <1f659c88-4d9d-8fc9-733a-5e6068f9ed4a@yandex.ru> <87a6o3x5j7.fsf@gmail.com> <87y2bnv5xc.fsf@gmail.com> <35be6652-9c8d-ee21-e9eb-9598ad6777eb@yandex.ru> <858682b2-b8fd-898b-bef3-97dbe5e4debc@yandex.ru> <878s3gugqj.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36520"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Stefan Monnier , 48841@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 13 16:30:33 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lsR8D-0009Is-Ak for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Jun 2021 16:30:33 +0200 Original-Received: from localhost ([::1]:43848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsR8B-0007Yp-JT for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Jun 2021 10:30:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsR7j-0007YT-8j for bug-gnu-emacs@gnu.org; Sun, 13 Jun 2021 10:30:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsR7i-0003o1-TT for bug-gnu-emacs@gnu.org; Sun, 13 Jun 2021 10:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lsR7i-0005G9-Qo for bug-gnu-emacs@gnu.org; Sun, 13 Jun 2021 10:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Jun 2021 14:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48841 X-GNU-PR-Package: emacs Original-Received: via spool by 48841-submit@debbugs.gnu.org id=B48841.162359458620166 (code B ref 48841); Sun, 13 Jun 2021 14:30:02 +0000 Original-Received: (at 48841) by debbugs.gnu.org; 13 Jun 2021 14:29:46 +0000 Original-Received: from localhost ([127.0.0.1]:44176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsR7R-0005FB-UZ for submit@debbugs.gnu.org; Sun, 13 Jun 2021 10:29:46 -0400 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:38711) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsR7P-0005Ex-E1 for 48841@debbugs.gnu.org; Sun, 13 Jun 2021 10:29:44 -0400 Original-Received: by mail-wm1-f51.google.com with SMTP id t4-20020a1c77040000b029019d22d84ebdso11305501wmi.3 for <48841@debbugs.gnu.org>; Sun, 13 Jun 2021 07:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=/R8iY8ERrZ3TRuY7uXH+hyClzItdnd/yDz57yx2q/8g=; b=A82QEDikrlKbVAF+TvxrkOfzgp6lK+S5ZI42UCCZtoTnQcYMkgwpKCqOoPV3VCqmGQ 3fSnSDwvt0t9jOGsO1iOC4ROpFbU0cPfops5Eub0c++A75VFRpOplCw+1axJN7whEo80 +i+Bt6dYl/iIWm8Y7mmpvfnNqoqK4CPVlcSN6SJ2rilGoWM7rzJiPxQmQwPJgyYxetWq sc3u/v5RzZCQfutoenwGJBx6rb3WyPTiuP0cP1uUnV7yELnlGvBKPnEtqtiiuioZDxzd xhBkDMHGy8XptD5oIDZTJSZABprsglL58maAdr3MEwCNHHnbBY3RkJxScwrjjZ8ml3Ds 3W3Q== 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:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=/R8iY8ERrZ3TRuY7uXH+hyClzItdnd/yDz57yx2q/8g=; b=KbsQP8rC3E8oH+mIFBdFAIqKtVSrtHcbGX92klUsqZG1JtN3FxOkQJ4RUo8Zc655YB N884SZdALl9sMKMsqYeyGtUDlWlY7gN9VOo/6ZDB54+zAotu37O8JNpCU7Gh1374Abez F2Gmn5v4+WQ90Qv+r3kRzjRCi//Dmb3TPbMWeOsYADNAZ0SPQKdgUBEe239vVNPMBUpt kTwWqZy6a6YGGjeDE7HGgk6aSS2l0ShcvQvnySl1AUoLyte2RHB6B/ChzEQgNbpK4VKh S8xyHxleKGSs7qusBY0+qhaQ3WJ7zJjxV2WYRDMfpr9XheUkBfVbkHykwTb0RYpXKA8x QSEg== X-Gm-Message-State: AOAM532TkXDiJaoxRnTb7alDw4vZGgEJtxfJ8Km7y4u5EzF3C/Z4xl3y GiGgnI4GzLJ9tYgPFqZwM6xQvO4+fmg= X-Google-Smtp-Source: ABdhPJzBqzlRg3ZavlOoWI1jLe6YxFHExs+27Z4Pz1+HGeUv7SwGCIurWUecS732LgQxCyQtaTSRyA== X-Received: by 2002:a7b:c4d2:: with SMTP id g18mr11946303wmk.25.1623594577064; Sun, 13 Jun 2021 07:29:37 -0700 (PDT) Original-Received: from krug (a94-133-55-152.cpe.netcabo.pt. [94.133.55.152]) by smtp.gmail.com with ESMTPSA id l9sm11008989wme.21.2021.06.13.07.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Jun 2021 07:29:36 -0700 (PDT) In-Reply-To: (Dmitry Gutov's message of "Sat, 12 Jun 2021 03:43:43 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:208441 Archived-At: Dmitry Gutov writes: > On 12.06.2021 02:24, Jo=C3=A3o T=C3=A1vora wrote: >> Dmitry Gutov writes: >>=20 >>> Looking forward for your analysis of fido-vertical-mode's performance >>> improvement over the "normal" one. >> So, I benchmarked before and after this patch to icomplete.el: >> diff --git a/lisp/icomplete.el b/lisp/icomplete.el >> index 08b4ef2030..3561ebfa04 100644 >> --- a/lisp/icomplete.el >> +++ b/lisp/icomplete.el >> @@ -858,16 +858,8 @@ icomplete-completions >> ;; removing making `comps' a proper list. >> (base-size (prog1 (cdr last) >> (if last (setcdr last nil)))) >> - (most-try >> - (if (and base-size (> base-size 0)) >> - (completion-try-completion >> - name candidates predicate (length name) md) >> - ;; If the `comps' are 0-based, the result should= be >> - ;; the same with `comps'. >> - (completion-try-completion >> - name comps nil (length name) md))) >> - (most (if (consp most-try) (car most-try) >> - (if most-try (car comps) ""))) >> + (most-try nil) >> + (most "") >> ;; Compare name and most, so we can determine if na= me is >> ;; a prefix of most, or something else. >> (compare (compare-strings name nil nil > > All right, so this is not about try-completion, it's about > completion-try-completion. That makes sense. Yeah, to be honest, once I'm done actually using these functions I immediately evict the differences between try-completion, completion-try-completion, try-try-completion-completion, or any of these yoda-speak variations from my mental cache.=20=20 Here I meant is that there was something apparently useless and slow (to fido-mode at least) going on in that else branch. > Elapsed time: 0.329006s (0.246073s in 10 GCs) > > vs > > Elapsed time: 0.169200s (0.113762s in 5 GCs) > > I suppose the 40-70ms difference is due to delay in typing. No idea. In my (slower?) system, I typed C-u C-x C-e C-m pretty fast. Presumably the C-m goes in before pp-eval-last-sexp has a chance to read more input so I wouldn't think it's a delay in typing. I could investigate, but since your measurements confirm the same tendency anyway, I think this simple patch is what's needed to close this issue. diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 08b4ef2030..5d37f47e7d 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -859,13 +859,14 @@ icomplete-completions (base-size (prog1 (cdr last) (if last (setcdr last nil)))) (most-try - (if (and base-size (> base-size 0)) - (completion-try-completion - name candidates predicate (length name) md) - ;; If the `comps' are 0-based, the result should be - ;; the same with `comps'. - (completion-try-completion - name comps nil (length name) md))) + (and (not fido-mode) ; Fido avoids these expensive calcula= tions. + (if (and base-size (> base-size 0)) + (completion-try-completion + name candidates predicate (length name) md) + ;; If the `comps' are 0-based, the result should be + ;; the same with `comps'. + (completion-try-completion + name comps nil (length name) md)))) (most (if (consp most-try) (car most-try) (if most-try (car comps) ""))) ;; Compare name and most, so we can determine if name is Jo=C3=A3o