From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74561: [PATCH] Allow limiting the size of *Completions* Date: Fri, 29 Nov 2024 09:45:33 -0500 Message-ID: References: Reply-To: Spencer Baugh Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29130"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: dmitry@gutov.dev, 74561@debbugs.gnu.org, juri@linkov.net To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 29 15:46:44 2024 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 1tH2GZ-0007QE-JP for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Nov 2024 15:46:43 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tH2GQ-0000wh-UN; Fri, 29 Nov 2024 09:46:35 -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 1tH2G6-0000Yq-33 for bug-gnu-emacs@gnu.org; Fri, 29 Nov 2024 09:46:18 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tH2Fx-0001Bw-LG for bug-gnu-emacs@gnu.org; Fri, 29 Nov 2024 09:46:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=M7UY3hy74cfh7Ku/0Erb7oS+MfVL/xb6rluz+cMUam4=; b=qGJ4MovFGoVdCSyDRlfhFN2ujaTcmXfMzFQ8vcCtvRv9ZJSfmqOoxaa6HMXgQtWcQLKP2vTZVkVF8ut84mMxkKOxbn6nw21eoXizSBr+68m8zrk0Ea21iMkvNa+8ugeqHdbibAHj0JStMea+s87+zz1+aJuZfJA9dp4CMGUDsmYaCjgj/5Pln1ZVqYwZ3SqL7dn5ciNFmWPwZYX2B+L4rz4gHNibehHd2VBQZDecSKVdwp7W0V3XzJSTBUf22mtrQasn0vWmEVhWypElPK67DgZG6ZmRAbvNDD7T3p3vt13wTV1qOVhUOW3tRO9Pt4w8GW2TghC+K8uByl1JuArfAg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tH2Fx-0004Cp-Fa for bug-gnu-emacs@gnu.org; Fri, 29 Nov 2024 09:46:05 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Nov 2024 14:46:05 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74561 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 74561-submit@debbugs.gnu.org id=B74561.173289155216099 (code B ref 74561); Fri, 29 Nov 2024 14:46:05 +0000 Original-Received: (at 74561) by debbugs.gnu.org; 29 Nov 2024 14:45:52 +0000 Original-Received: from localhost ([127.0.0.1]:41740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tH2Fj-0004BY-Pr for submit@debbugs.gnu.org; Fri, 29 Nov 2024 09:45:52 -0500 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:41161) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tH2FW-0004Ax-QH for 74561@debbugs.gnu.org; Fri, 29 Nov 2024 09:45:39 -0500 In-Reply-To: (Stefan Monnier's message of "Thu, 28 Nov 2024 23:12:59 -0500") DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1732891533; bh=M7UY3hy74cfh7Ku/0Erb7oS+MfVL/xb6rluz+cMUam4=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=ZzsMipJcTvqfqxCDz47gLivqXOTFAtJy81T/z70y/N3tmhi9aPevqxSucEHP233X/ vBdBs436CpaovW4igOQYOdN4b4djjmS6qXSrxFnLhs1mCSePaP57OKAHjLNVvXRPMC LAzJdBDeTHdoSk7ZzXFy1Jal80q6xieVrGq0tuy/NvKxoZmBPFkHAf7WTbyf0Y1IMg 8qO4Gq/QZ5yCNA6DuB/LKnVUCB1SHLd37/JmR3/dT444J9/JKnCj+iUaoJjRzs+JbW pc3uBTFXLwUTPxEjVljk4hNXeGPf6/Kvgfudg5RM0lcbJb8tdpcFrXghiuN/mlXPtT QlgwyxRqwQaeQ== 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:296092 Archived-At: Stefan Monnier writes: >> From profiling, the main bottleneck in completion over large >> completion sets is display-completion-list, when there are many >> available candidates. > > Hmm... interesting. I expected it would be the computation of faces > from things like `completion-pcm--hilit-commonality`. > > Do you happen to know which part of `display-completion-list` is the > most costly? is it the actual insertion into the buffer? A simple way to profile this is: (progn (require 'profiler) (profiler-reset) (profiler-cpu-start 10000) (completing-read ":" (mapcar #'number-to-string (number-sequence 0 100000))) (profiler-cpu-stop) (setq profiler-cpu-log (profiler-cpu-log)) (profiler-report-cpu)) The biggest individual contributors of runtime are set/add-text-properties and insert. > I think we should try and fill the buffer lazily. We don't have much > experience with "jit" populating a buffer (the closest I can think of is > the `vlf` package, which doesn't do "jit", IIRC), so it may take some > trial-and-error until we have something that works, but it > seems worthwhile. Yes, I think filling the *Completions* buffer lazily would be way better than limiting the size of the buffer, thanks everyone for your comments. I think it would be sufficient to do something simple, and just split filling the *Completions* buffer into two parts: - In minibuffer-completion-help, insert only enough completion candidates that the part of the *Completions* buffer that's displayed in a window initially looks normal. Save the rest of the completions in a buffer-local in *Completions*. - Upon any kind of interaction with the *Completions* buffer, insert all the rest of the completion candidates in completions--finish-populate. We could be lazier than this, but this is probably sufficient to give a big speedup, since I think *Completions* is rendered much more often than it's interacted with. So to do this, all we need is a way to do completions--finish-populate at the right time. I'm not sure when to do that. Maybe we could just call it in window-selection-change-functions and with-minibuffer-completions-window and maybe a few other places?