-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
describe-variable is slow with many variables due to buffer switching in predicate #40
Comments
EDIT: Two questions: Which completion style do you use and with which system do you compare, Selectrum? I use Orderless with the default literal and regexp matching styles with my custom style dispatcher. Maybe you use the Emacs flex style, which is slower because the flex regexps are more expensive to match. |
@minad Thanks for the info. I just tried I am using orderless (I am essentially using exactly what is in the readme in this repo). |
Ah okay, there could be some issue at play here specifically with the variable completion table only. The variable table has some kind of bad logic inside which expects the table to be called in a certain context. Selectrum had the same problem. I will investigate. |
Are you also using Marginalia with full annotations turned on? I've got 20k+ results in |
@daviwil Native is cheating ;) |
@jacksonludwig Please give the branch optimize-describe-var a try, see 5b6d95f. Does this improve the situation for you? Generally I am not a fan of such special casing since this will ultimately lead to the accumulation of cruft. |
@daviwil Regarding annotations, these are computed lazily only for the visible candidate and should never make issues with Vertico. Otherwise the UI performance would be horrible. |
Good to know! That's a great way to do it. |
@jacksonludwig I am not sure if I can reproduce this issue.
(dotimes (i 100000)
(eval `(defvar ,(intern (format "test-var%s" i)) nil)))
Of course there is a noticeable lag, but the UI stays responsive. Vertico already has an optimization which ensures that the running computation is aborted when new input comes in. For me this is still usable even with 100k items. Line 304 in 030b964
|
FWIW I'm on a 2020 iMac (emacs 27.2) and describe-variable with about 12k candidates using vertico is very responsive. |
@minad Out of curiosity, are these normal profiler results? This is what I get from calling
versus this from calling
And this is with |
The second profiler result looks quite normal. Most of the time is spent in the Which Emacs version and which os do you use? Can you observe the difference also on emacs -Q, when loading only Vertico and nothing else? |
I use ubuntu and I'm using the latest master with native comp for emacs. With -Q, I did have less stutter but it was still noticeable after I added dummy variables to match what is usually available with other packages installed (I had around 15k vars). However, I did see something odd. When running To test it, I opened a python file and called |
Do you use marginalia-mode? Can you test this with Marginalia disabled? But the profile you collected is odd, and points to the predicate being the issue. Did you also test with 5b6d95f? |
For me having marginalia enabled/disabled has no difference. And when I tested with -Q I used the following config:
|
Okay, I suggest you experiment a bit with the help--symbol-completion-table. describe-symbol (This is fast for you?): (val (completing-read (if found
(format
"Describe symbol (default %s): " v-or-f)
"Describe symbol: ")
#'help--symbol-completion-table
(lambda (vv)
(cl-some (lambda (x) (funcall (nth 1 x) vv))
describe-symbol-backends))
t nil nil
(if found (symbol-name v-or-f))))) describe-variable (This one is slow): (setq val (completing-read
(if (symbolp v)
(format
"Describe variable (default %s): " v)
"Describe variable: ")
#'help--symbol-completion-table
(lambda (vv)
;; In case the variable only exists in the buffer
;; the command we switch back to that buffer before
;; we examine the variable.
(with-current-buffer orig-buffer ;; Note the buffer switching
(or (get vv 'variable-documentation)
(and (boundp vv) (not (keywordp vv))))))
t nil nil
(if (symbolp v) (symbol-name v)))) The difference is in the predicate. You can copy the (lambda (vv)
(or (get vv 'variable-documentation)
(and (boundp vv) (not (keywordp vv))))) |
@minad |
The slower predicate is also correct. I mean, I'd expect |
Of course it should be correct. I am often using describe-variable+Marginalia to check some buffer values without actually executing the command. One could add some special casing. For example "normalize" the completion table early on using all-completions. |
Fixed in Emacs 28, closing here. |
I noticed that when using vertico in a situation where there are many results (e.g.
C-h v
lists 12 thousand+ items for me), there is noticeable lag when typing until the search is narrowed enough.Is this just emacs's fault? Or is there a way around it somehow?
Thank you for your efforts on this package.
The text was updated successfully, but these errors were encountered: