Tags: patch From profiling, the main bottleneck in completion over large completion sets is display-completion-list, when there are many available candidates. For example, in my large monorepo, when completing over the 589196 files or the 73897 branches, even with the candidates narrowed down by typing some prefix to complete, TAB (when it shows *Completions*) or ? is slow, mostly in display-completion-list. By adding completions-list-max with a very large default, performance is greatly improved in these situations without impacting the normal case of completion on reasonably sized sets. Limiting the work done by display-completion-list is also important for packages which auto-update *Completions* inside while-no-input: since display-completion-list doesn't do anything which reads input, while-no-input won't interrupt it. Such packages can instead just bind completions-list-max to a smaller value. * lisp/minibuffer.el (display-completion-list): Add FULL-COUNT argument. (completions-list-max): Add. (minibuffer-completion-help): Truncate completions based on completions-list-max. In GNU Emacs 29.2.50 (build 9, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-11-20 built on igm-qws-u22796a Repository revision: 28dc0b6f9987e0def7dff4deaa23aa60f021d2a7 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.10 (Green Obsidian) Configured using: 'configure --with-x-toolkit=lucid --without-gpm --without-gconf --without-selinux --without-imagemagick --with-modules --with-gif=no --with-tree-sitter --with-native-compilation=aot PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'