Skip to content
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

Slow selection with many files #276

Closed
SebastienWae opened this issue Dec 15, 2020 · 11 comments
Closed

Slow selection with many files #276

SebastienWae opened this issue Dec 15, 2020 · 11 comments

Comments

@SebastienWae
Copy link

SebastienWae commented Dec 15, 2020

Opening a new issue because #195 has been close for a few months.

Selectrum is very slow, 1-2 seconds delay between each key press and ui update, on a 61k+ list of file.

I have tried with and without orderless and prescient, it didn't made any changes.
Ivy with and without prescient has a much lower delay ~500 ms.

This is using Emacs native-comp branch on NixOS.
output

@clemera
Copy link
Collaborator

clemera commented Dec 15, 2020

Oh, that are a lot of files :D

The problem is with file completions as I tested with

touch {1..60000}

And start completion using find-file, there is no problem with such large candidates sets in general:

(completing-read "Check: "
                 (mapcar #'number-to-string
                         (number-sequence 0 60000)))

This might also be connected to the reported tramp issues #210

@minad
Copy link
Contributor

minad commented Dec 15, 2020

@clemera But if you use numbers, the strings are much shorter. I am sure this has some effect. Did you test many long strings? I mean there are the issues with long strings in the consult-help experiment.

@clemera
Copy link
Collaborator

clemera commented Dec 15, 2020

Yes that also has an effect but the file problem still exists with the number example. The problem seems to be that the internal collection function is unusable slow with so many file as you can test using:

(read-file-name-internal "~/playground/files/" nil t)

@clemera
Copy link
Collaborator

clemera commented Dec 15, 2020

We call it on every input change I guess a simple workaround would be to only recompute on directory change for file completions, that would still give you an initial delay but not on every keypress afterwards.

@minad
Copy link
Contributor

minad commented Dec 15, 2020

Maybe check what ivy does differently - is there some internal API they work around and Selectrum cannot?

We call it on every input change I guess a simple workaround would be to only recompute on directory change for file completions, that would still give you an initial delay but not on every keypress afterwards.

This would fix the lagging when pressing keys.

@clemera
Copy link
Collaborator

clemera commented Dec 15, 2020

Maybe check what ivy does differently - is there some internal API they work around and Selectrum cannot?

I checked and they use the same function, they are also equally slow initially but the result is cached so there is no lag on each input for ivy.

@clemera clemera changed the title Slow selection with large lists Slow selection with many files Dec 15, 2020
@clemera
Copy link
Collaborator

clemera commented Dec 15, 2020

@SebastienWae
Could you test if #277 would work for you? Please disable sort before testing this by setting selectrum-should-sort-p to nil.

@SebastienWae
Copy link
Author

@SebastienWae
Could you test if #277 would work for you? Please disable sort before testing this by setting selectrum-should-sort-p to nil.

It's much better!
I haven't timed it, but with sort enabled it feels at least as fast as Ivy and when disabled it's much faster.

Initial load time is still slow (but that's not really a Selectrum issue) and once it's loaded it only has a small delay which is more than acceptable considering the size of the list.

gif with sort enable:
output

@minad
Copy link
Contributor

minad commented Dec 15, 2020

Initial load time is still slow (but that's not really a Selectrum issue) and once it's loaded it only has a small delay which is more than acceptable considering the size of the list.

Slower than ivy?

@SebastienWae
Copy link
Author

SebastienWae commented Dec 15, 2020

Initial load time is still slow (but that's not really a Selectrum issue) and once it's loaded it only has a small delay which is more than acceptable considering the size of the list.

Slower than ivy?

I would have to benchmark it to be sure but it feels the same at ~1-2 seconds.
But the most important part is that once it's load it fast enough that I can use it.

@clemera
Copy link
Collaborator

clemera commented Dec 16, 2020

With #277 merged can this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants