From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#48841: fido-mode is slower than ido-mode with similar settings Date: Sat, 12 Jun 2021 03:43:43 +0300 Message-ID: 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; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4215"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 Cc: Stefan Monnier , 48841@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 12 02:44:16 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 1lrrl1-0000sv-PF for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Jun 2021 02:44:15 +0200 Original-Received: from localhost ([::1]:34424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrrl0-0004JK-9x for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 11 Jun 2021 20:44:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrrko-0004It-0n for bug-gnu-emacs@gnu.org; Fri, 11 Jun 2021 20:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lrrkn-00078Q-Pi for bug-gnu-emacs@gnu.org; Fri, 11 Jun 2021 20:44:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lrrkn-0006R2-Me for bug-gnu-emacs@gnu.org; Fri, 11 Jun 2021 20:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Jun 2021 00:44:01 +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.162345863424715 (code B ref 48841); Sat, 12 Jun 2021 00:44:01 +0000 Original-Received: (at 48841) by debbugs.gnu.org; 12 Jun 2021 00:43:54 +0000 Original-Received: from localhost ([127.0.0.1]:40122 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrrkf-0006QZ-TT for submit@debbugs.gnu.org; Fri, 11 Jun 2021 20:43:54 -0400 Original-Received: from mail-wr1-f51.google.com ([209.85.221.51]:34393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lrrkd-0006QK-7E for 48841@debbugs.gnu.org; Fri, 11 Jun 2021 20:43:52 -0400 Original-Received: by mail-wr1-f51.google.com with SMTP id q5so7729166wrm.1 for <48841@debbugs.gnu.org>; Fri, 11 Jun 2021 17:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pmAjKVCdbcmleM697UMZh8BoBJqY0GBHaUmnU8e9u5c=; b=e/ByEfoP5a72FCwYwwqyrzLboifymVYLa5iQJj4RO8GJQ5qL5C4VDJnljoB5FVTfOT zLrdWQBkaQYQmw5RAdKKnbL0ffcHtjfb9FAbqxSecIk02/DWvD2o6cgERxhbSy9mjz9z 9E2uFJAaVAddE6Wi/XkXX2yjUBoBCNVxfNDiNQXocKCzvAQRI6feeZhhBrrPcgdaZBT5 1cWVM404cj7gkJHC+PFNIsJb91unM8hMXLHj+u+GZw7tApx4u37ZvFRij+jTBNkomJM9 HVDCxGUEWheF5KCvRu16+zzSVhcEVaz/pqP0EVGiE/pz/5TJ5EdABj1KV7+pOk3HyKFk fSEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pmAjKVCdbcmleM697UMZh8BoBJqY0GBHaUmnU8e9u5c=; b=Vn+HxpAFdN5wWvXawGV8fk79afAJbQ/ukaj+6b/zz3UmJhRhpgtQB51lQLvXVQqS5u CnZSXFEl+k5KY1Cw5wz3XGXUOZGNv6J8SwXGBbWSRV0/TRPb7LBd3axV+R9dX5taL+3f vdAzdYlPbtPsRyCXAno9SAv8NtpO5xpVo4nz60i59Uqv2oeSCLWj1FkDXlaCjYFmpY95 2R1yKAmQZIidOXwkWsRr5XDOw5MsZqPyAYhiASORgpx2i1ut+34akJs+ep/Os0+Tek9Y aHWcs1LvWyQGRM5RzzVAxT62zLuM0gMhqLUg2wD/TnRC7ej8XsV/vfO+MMv81EwwCSLZ BxuA== X-Gm-Message-State: AOAM530QtHVhBxe/L26oOT/VQX6BeqkiUBALyZi5yd2cFpkMCRnX0IaT ma1yw7+5efmizrVGHDhlBE+aexjrQ0c= X-Google-Smtp-Source: ABdhPJw1RrHBjEXdE+Fo1GHbEVdlMze+chzZC1h3bt+C4w15ub7zHnsUrUC3hL41s2rO+VQnkGqTXg== X-Received: by 2002:a5d:48ce:: with SMTP id p14mr6725793wrs.170.1623458625046; Fri, 11 Jun 2021 17:43:45 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id l9sm7411716wme.21.2021.06.11.17.43.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Jun 2021 17:43:44 -0700 (PDT) In-Reply-To: <878s3gugqj.fsf@gmail.com> Content-Language: en-US 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:208362 Archived-At: On 12.06.2021 02:24, João Távora wrote: > Dmitry Gutov writes: > >> 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 name 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. > The patch itself nullifies the calculation of the 'determ' thing that I > and presumably some other users don't value that much. It doesn't > affect fido-mode's basic funcionality. > > How did I benchmark? Well, to measure the delay the user experiences > until all completions are presented I had to take out the > `while-no-input` in icomplete-exhibit so that this test would work: > > ;; After the form, type C-u C-x C-e C-m in quick succession > (benchmark-run (completing-read "bla" obarray)) > > If I don't remove this `while-no-input`, icomplete will not lose time > showing all the completions and will instead select just the first one. > That's a very nice feature for actual use, but for this benchmark that > is not what I want: I want to measure the time to show all the > completions. Did the same, can repro. > Then, the times presented by benchmark-run are the same that the user > sees if he waits to see the completions. Now the values: > > Before my patch: > > (1.802209488 5 1.3678843490000077) > (1.609066281 4 1.1170432569999775) > (1.878972079 5 1.3725165670000479) > (1.901952581 5 1.3979494059999524) > (1.820800064 5 1.3283940110000003) > > After the patch: > > (0.552051921 1 0.3079724459999511) > (0.58396499 1 0.3038616050000087) > (0.861106587 2 0.6046198220000178) > (0.611551175 1 0.30275532399997473) > (0.62500199 1 0.3160454470000218) I get (0.377195885 10 0.24448539800000013) before and (0.245218061 6 0.1390041310000001) after. A solid improvement. BTW, if I just stick benchmark-progn around icomplete-completions like diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 08b4ef2030..b9fe3e1836 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -678,12 +678,13 @@ icomplete-exhibit ;; seems to trigger it fairly often! (while-no-input-ignore-events '(selection-request)) (text (while-no-input - (icomplete-completions - field-string - (icomplete--completion-table) - (icomplete--completion-predicate) - (if (window-minibuffer-p) - (eq minibuffer--require-match t))))) + (benchmark-progn + (icomplete-completions + field-string + (icomplete--completion-table) + (icomplete--completion-predicate) + (if (window-minibuffer-p) + (eq minibuffer--require-match t)))))) (buffer-undo-list t) deactivate-mark) ;; Do nothing if while-no-input was aborted. ...it reports 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.